Class PriorityQueueAbstract<E>

  • Direct Known Subclasses:
    NonpriorityQueue, PriorityQueueRelaxed, PriorityQueueStrict

    public abstract class PriorityQueueAbstract<E>
    extends java.lang.Object
    Works like a LinkedBlockingQueue using the put() and take() methods but with an additional priority integer parameter. The elemnt returned from take() will honor the priority in such a way that all elements of a lower priority will be returned before any elemens of a higher priority.
    Modified proposition taken from Noa Resare: http://resare.com/noa/ref/MultiPrioQueue.java
    Author:
    Artur Hefczyc
    • Field Detail

      • NONPRIORITY_QUEUE

        public static final java.lang.String NONPRIORITY_QUEUE
        See Also:
        Constant Field Values
      • QUEUE_IMPLEMENTATION

        public static final java.lang.String QUEUE_IMPLEMENTATION
        See Also:
        Constant Field Values
    • Constructor Detail

      • PriorityQueueAbstract

        public PriorityQueueAbstract()
    • Method Detail

      • getPriorityQueue

        @Deprecated
        public static <E> PriorityQueueAbstract<E> getPriorityQueue​(int maxPriority,
                                                                    int maxSize)
        Deprecated.
      • init

        public abstract void init​(int maxPriority,
                                  int maxSize)
      • offer

        public abstract boolean offer​(E element,
                                      int priority)
      • put

        public abstract void put​(E element,
                                 int priority)
                          throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • setMaxSize

        public abstract void setMaxSize​(int maxSize)
      • size

        public abstract int[] size()
      • take

        public abstract E take()
                        throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • totalSize

        public abstract int totalSize()