Module logicng

Class LNGHeap


  • public final class LNGHeap
    extends Object
    A minimalistic heap implementation.
    Since:
    1.0
    Version:
    1.3
    • 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()
        Returns true if the heap ist empty, false otherwise.
        Returns:
        true if the heap ist empty
      • inHeap

        public boolean inHeap​(int n)
        Returns true if a given element is in the heap, false otherwise.
        Parameters:
        n - the element
        Returns:
        true if 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.