Class PriorityQueueExt<T>


  • @ParametersAreNonnullByDefault
    public final class PriorityQueueExt<T>
    extends java.lang.Object
    Binary heap-based priority queue.

    Optimizations (compared to PriorityQueueExt):

    • We not extract keys from objects when comparing them. Instead we store keys in separate array.
    • When root removed, we don't update tree structure immediately. Instead we mark that root is missing and update structure
    • Constructor Summary

      Constructors 
      Constructor Description
      PriorityQueueExt​(int capacity, boolean ascending)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      void dump​(java.io.PrintStream ps)  
      void dump​(java.io.PrintStream ps, java.lang.String indent, int pos)  
      boolean isEmpty()  
      void offer​(T obj, long objKey)  
      long peekKey()  
      T poll()  
      boolean remove​(T obj)  
      int size()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PriorityQueueExt

        public PriorityQueueExt​(int capacity,
                                boolean ascending)
    • Method Detail

      • dump

        public void dump​(java.io.PrintStream ps)
      • dump

        public void dump​(java.io.PrintStream ps,
                         java.lang.String indent,
                         int pos)
      • clear

        public void clear()
      • size

        public int size()
      • isEmpty

        public boolean isEmpty()
      • offer

        public void offer​(T obj,
                          long objKey)
      • remove

        public boolean remove​(T obj)
      • poll

        @Nullable
        public T poll()
      • peekKey

        public long peekKey()
        Returns:
        returns current key of root.