All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sdsu.util.CharQueue

java.lang.Object
   |
   +----sdsu.util.CharQueue

public final class CharQueue
extends Object
This class implements a characater queue. Yes the JKD does contain a general queue. However that queue operates on objects. This queue just handles char elements. Use in IO operations where converting chars to objects will be too expensive.

Version:
1.0 21 August 1997
Author:
Roger Whitney (whitney@cs.sdsu.edu)

Variable Index

 o DEFAULT_QUEUE_SIZE

Constructor Index

 o CharQueue()
 o CharQueue(int)

Method Index

 o capacity()
Returns the current number of locations for chars in queue
 o clear()
Clears the queue so it has no more elements in it
 o dequeue()
Removes front char from the queue and returns the char
 o dequeue(char[])
Fills charsRemoved with chars removed from the queue.
 o dequeue(char[], int, int)
Places chars from queue in charsRemoved starting at charsRemoved[offset].
 o dequeueAll()
Returns an array containing all chars in the queue.
 o enqueue(char)
Adds charToAdd to the end of the queue
 o enqueue(char[])
Adds all elements of charsToAdd to the end of the queue
 o enqueue(char[], int, int)
Adds numCharsToAdd elements of charsToAdd, starting with charsToAdd[offset] to the end of the queue
 o enqueue(String)
Adds charsToAdd to the end of the queue
 o isEmpty()
Returns true if the queue is empty
 o isFull()
Returns true if the queue is full
 o peek()
Returns the front char from the queue without removing it
 o size()
Returns the number of chars in the queue
 o toString()
Returns string representation of the queue
 o unusedCapacity()
Returns the current number of unused locations in the queue

Variables

 o DEFAULT_QUEUE_SIZE
 public static final int DEFAULT_QUEUE_SIZE

Constructors

 o CharQueue
 public CharQueue(int Size)
 o CharQueue
 public CharQueue()

Methods

 o capacity
 public int capacity()
Returns the current number of locations for chars in queue

 o isEmpty
 public boolean isEmpty()
Returns true if the queue is empty

 o isFull
 public boolean isFull()
Returns true if the queue is full

 o size
 public int size()
Returns the number of chars in the queue

 o toString
 public String toString()
Returns string representation of the queue

Overrides:
toString in class Object
 o unusedCapacity
 public int unusedCapacity()
Returns the current number of unused locations in the queue

 o dequeue
 public char dequeue()
Removes front char from the queue and returns the char

 o dequeue
 public int dequeue(char charsRemoved[])
Fills charsRemoved with chars removed from the queue. If charsRemoved is larger than queue then charsRemoved is not completely filled

Returns:
actual number of chars put in charsRemoved
 o dequeue
 public int dequeue(char charsRemoved[],
                    int offset,
                    int numCharsRequested)
Places chars from queue in charsRemoved starting at charsRemoved[offset]. Will place numCharsRequested into charsRemoved if queue has enougth chars.

Returns:
actual number of chars put in charsRemoved
 o dequeueAll
 public char[] dequeueAll()
Returns an array containing all chars in the queue. Afterwards queue is empty.

 o peek
 public char peek()
Returns the front char from the queue without removing it

 o enqueue
 public void enqueue(char charToAdd)
Adds charToAdd to the end of the queue

 o enqueue
 public void enqueue(String charsToAdd)
Adds charsToAdd to the end of the queue

 o enqueue
 public void enqueue(char charsToAdd[])
Adds all elements of charsToAdd to the end of the queue

 o enqueue
 public void enqueue(char charsToAdd[],
                     int offset,
                     int numCharsToAdd)
Adds numCharsToAdd elements of charsToAdd, starting with charsToAdd[offset] to the end of the queue

 o clear
 public void clear()
Clears the queue so it has no more elements in it


All Packages  Class Hierarchy  This Package  Previous  Next  Index