Interface DoubleObjectHeap<V>

  • Type Parameters:
    V - Value type
    All Known Implementing Classes:
    DoubleObjectMaxHeap, DoubleObjectMinHeap

    public interface DoubleObjectHeap<V>
    Basic in-memory heap interface, for double keys and Object values.

    This class is generated from a template.

    Since:
    0.6.0
    Author:
    Erich Schubert
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  DoubleObjectHeap.UnsortedIter<V>
      Unsorted iterator - in heap order.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void add​(double key, V val)
      Add a key-value pair to the heap
      void add​(double key, V val, int k)
      Add a key-value pair to the heap if it improves the top.
      void clear()
      Clear the heap contents.
      boolean containsKey​(double q)
      Contains operation for a key (slow: with a linear scan).
      boolean containsValue​(V q)
      Contains operation for a value (slow: with a linear scan).
      boolean isEmpty()
      Is the heap empty?
      double peekKey()
      Get the current top key.
      V peekValue()
      Get the current top value.
      void poll()
      Remove the first element.
      void replaceTopElement​(double key, V val)
      Combined operation that removes the top element, and inserts a new element instead.
      int size()
      Query the size.
      DoubleObjectHeap.UnsortedIter<V> unsortedIter()
      Get an unsorted iterator to inspect the heap.
    • Method Detail

      • add

        void add​(double key,
                 V val)
        Add a key-value pair to the heap
        Parameters:
        key - Key
        val - Value
      • add

        void add​(double key,
                 V val,
                 int k)
        Add a key-value pair to the heap if it improves the top.
        Parameters:
        key - Key
        val - Value
        k - Desired maximum size
      • replaceTopElement

        void replaceTopElement​(double key,
                               V val)
        Combined operation that removes the top element, and inserts a new element instead.
        Parameters:
        key - Key of new element
        val - Value of new element
      • peekKey

        double peekKey()
        Get the current top key.
        Returns:
        Top key
      • peekValue

        V peekValue()
        Get the current top value.
        Returns:
        Value
      • containsKey

        boolean containsKey​(double q)
        Contains operation for a key (slow: with a linear scan).
        Parameters:
        q - Key
        Returns:
        true if the key is contained in the heap.
      • containsValue

        boolean containsValue​(V q)
        Contains operation for a value (slow: with a linear scan).
        Parameters:
        q - Value
        Returns:
        true if the value is contained in the heap.
      • poll

        void poll()
        Remove the first element.
      • clear

        void clear()
        Clear the heap contents.
      • size

        int size()
        Query the size.
        Returns:
        Size
      • isEmpty

        boolean isEmpty()
        Is the heap empty?
        Returns:
        true when the size is 0.