- java.lang.Object
-
- org.logicng.solvers.datastructures.LNGHeap
-
public final class LNGHeap extends Object
A minimalistic heap implementation.- Since:
- 1.0
- Version:
- 1.3
-
-
Constructor Summary
Constructors Constructor Description LNGHeap(MiniSatStyleSolver solver)Constructs a new heap for a given solver.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuild(LNGIntVector ns)Rebuilds the heap from a given vector of elements.voidclear()Clears the heap.voiddecrease(int n)Decrease an element's position in the heapbooleanempty()Returnstrueif the heap ist empty,falseotherwise.intget(int index)Returns the element at a given position in the heap.booleaninHeap(int n)Returnstrueif a given element is in the heap,falseotherwise.voidinsert(int n)Inserts a given element in the heap.voidremove(int n)Removes a given element of the heap.intremoveMin()Removes the minimal element of the heap.intsize()Returns the size of the heap.StringtoString()
-
-
-
Constructor Detail
-
LNGHeap
public LNGHeap(MiniSatStyleSolver solver)
Constructs a new heap for a given solver. The solver is required to access its activity information stored for variables. The initial size of the heap is 1000 elements.- Parameters:
solver- the solver
-
-
Method Detail
-
size
public int size()
Returns the size of the heap.- Returns:
- the size of the heap
-
empty
public boolean empty()
Returnstrueif the heap ist empty,falseotherwise.- Returns:
trueif the heap ist empty
-
inHeap
public boolean inHeap(int n)
Returnstrueif a given element is in the heap,falseotherwise.- Parameters:
n- the element- Returns:
trueif a given variable index is in the heap
-
get
public int get(int index)
Returns the element at a given position in the heap.- Parameters:
index- the position- Returns:
- the element at the position
-
decrease
public void decrease(int n)
Decrease an element's position in the heap- Parameters:
n- the element
-
insert
public void insert(int n)
Inserts a given element in the heap.- Parameters:
n- the element
-
removeMin
public int removeMin()
Removes the minimal element of the heap.- Returns:
- the minimal element of the heap
-
remove
public void remove(int n)
Removes a given element of the heap.- Parameters:
n- the element
-
build
public void build(LNGIntVector ns)
Rebuilds the heap from a given vector of elements.- Parameters:
ns- the vector of elements
-
clear
public void clear()
Clears the heap.
-
-