Documentation of 'jvx.util.PuQueue' Java class
PuQueue ("JavaView Reference Manual")
"JavaView? v5.03.003"
jvx.util

Class PuQueue



  • public class PuQueue
    extends java.lang.Object
    This class provides the functionality of a queue or a stack of integers. Elements can be inserted into the queue, and its youngest and oldest elements can be extracted (Thus, this queue is acting as a "first in first out" queue, or a "last in first out" stack). Internally, the elements are organized within an array, which is automatically expanded if the size is too small. Running time of all operations is O(1); the only exception is the enqueue operation, which has only amortized running time of O(log(n)), due to resizing.
    Author:
    Felix Kaelberer
    Version:
    06.09.09, 1.20 revised (fk) Implemented copyNew().
    13.12.06, 1.10 revised (mn) Implemented setSize() and changed the amount of dynamic resizing.
    16.01.06, 1.00 created (fk)
    • Constructor Summary

      Constructors 
      Constructor and Description
      PuQueue()
      Construct an empty queue.
      PuQueue(int size)
      Construct a queue with array of size size.
      PuQueue(int[] entries)
      Construct a queue the entries of a given array.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void copy(PuQueue queue)
      Copy all properties of the argument to this.
      static PuQueue copyNew(PuQueue queue)
      Create and return copy of this.
      void enqueue(int value)
      Insert an element into the queue.
      int extractFirst()
      Get the oldest element of the queue, i.e.the element which was inserted first.
      int extractLast()
      Get the youngest element of the queue, i.e.the element which was inserted last.
      int getNumEntries()
      Get number of elements in the queue.
      int getSize()
      Get maximum number of entries of the queue.
      boolean isEmpty()
      Whether the queue has no entries.
      void removeAll()
      Remove all elements from queue.
      void setSize(int size)
      Set the size of the queue.
      PiVector toPiVector()
      Create a PiVector with the entries of the queue.
      java.lang.String toString()
      Get a string containing all elements of the queue.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • PuQueue

        public PuQueue()
        Construct an empty queue.
      • PuQueue

        public PuQueue(int size)
        Construct a queue with array of size size. Initial number of entries is 0.
        Parameters:
        size - Size of the queue.
        Author:
        Felix Kaelberer
        Version:
        16.01.06, 1.00 created (fk)
      • PuQueue

        public PuQueue(int[] entries)
        Construct a queue the entries of a given array.
        Parameters:
        entries - Initial entries of the queue.
        Author:
        Felix Kaelberer
        Version:
        01.02.2007, 1.00 created (fk)
    • Method Detail

      • copy

        public void copy(PuQueue queue)
        Copy all properties of the argument to this.
        Parameters:
        queue - The queue to copy.
        Author:
        Felix Kaelberer
        Version:
        16.01.06, 1.00 created (fk)
      • copyNew

        public static PuQueue copyNew(PuQueue queue)
        Create and return copy of this.
        Parameters:
        queue - The queue to copy.
        Author:
        Felix Kaelberer
        Version:
        30.06.09, 1.00 created (fk)
      • getNumEntries

        public int getNumEntries()
        Get number of elements in the queue.
        Author:
        Felix Kaelberer
        Version:
        16.01.06, 1.00 created (fk)
      • getSize

        public int getSize()
        Get maximum number of entries of the queue.
        Version:
        06.12.06, 1.00 created (mn)
      • enqueue

        public void enqueue(int value)
        Insert an element into the queue. The queue is automatically enlarged, if required.
        Parameters:
        value - Item to enqueue.
        Author:
        Felix Kaelberer
        Version:
        16.01.06, 1.00 created (fk)
      • setSize

        public void setSize(int size)
        Set the size of the queue. Existing elements will be copied to the new data structures. If the size is smaller then the number of elements, then then last elements will be removed.
        Parameters:
        size - New size of the queue.
        Author:
        Matthias Nieser
        Version:
        13.12.06, 1.00 created (mn)
      • extractFirst

        public int extractFirst()
        Get the oldest element of the queue, i.e.the element which was inserted first.
        Author:
        Felix Kaelberer
        Version:
        16.01.06, 1.00 created (fk)
      • extractLast

        public int extractLast()
        Get the youngest element of the queue, i.e.the element which was inserted last.
        Author:
        Felix Kaelberer
        Version:
        16.01.06, 1.00 created (fk)
      • toString

        public java.lang.String toString()
        Get a string containing all elements of the queue.
        Overrides:
        toString in class java.lang.Object
        Author:
        Felix Kaelberer
        Version:
        07.02.07, 1.00 revised (fk) Separate entries with comma, use brackets.
        16.01.06, 1.00 created (fk)
      • toPiVector

        public PiVector toPiVector()
        Create a PiVector with the entries of the queue.
        Returns:
        PiVector of size getNumEntries() containing the entries of the queue.;
        Author:
        Felix Kaelberer
        Version:
        01.02.2007, 1.00 created (fk)
      • removeAll

        public void removeAll()
        Remove all elements from queue.
        Version:
        06.12.06, 1.00 created (mn)
      • isEmpty

        public boolean isEmpty()
        Whether the queue has no entries.
        Version:
        06.12.06, 1.00 created (mn)
"JavaView? v5.03.003"

"

The software JavaView? is copyright protected. All Rights Reserved.
"

Ads help maintain this website.