gishur.core
Class Queue

java.lang.Object
  |
  +--gishur.core.BasicList
        |
        +--gishur.core.Queue
All Implemented Interfaces:
java.lang.Cloneable, Cloneable, ControlledCloneable, Owner, java.io.Serializable

public class Queue
extends BasicList
implements ControlledCloneable

A simple queue based upon BasicList.

Version:
1.0
Author:
Thomas Wolf
See Also:
BasicList, Stack, Serialized Form

Fields inherited from class gishur.core.BasicList
ANY_ACCESS, KEY, LISTITEM, NO_ACCESS, VALUE
 
Fields inherited from interface gishur.core.ControlledCloneable
DEEP, FLAT
 
Constructor Summary
Queue()
          Empty constructor.
 
Method Summary
 void clear()
          Clears the whole queue.
 java.lang.Object clone()
          Implementation of Cloneable
clones the entire list by cloning the contained data-/keyobjects, if possible.
 java.lang.Object clone(java.util.Hashtable h, int level)
          clones the entire list according to ControlledCloneable.
 boolean contains(java.lang.Object object)
          Returns true, if object is stored in this Queue.
 java.lang.Object[] convertToArray()
          Converts this queue into an array.
 java.util.Enumeration elements()
          Returns an java.util.Enumerator-object which enumerates all elements of this queue.
 boolean empty()
          Returns true, if the queue is empty.
 java.lang.Object firstValue()
          Returns the first element in the Queue.
 ListView getListView()
          Creates and returns a ListView-object which enables full reading access to a BasicList wihtout knowing the explicite type.
 java.lang.Object lastValue()
          Returns the last element in the Queue.
 int length()
          Returns the number of stored elements in this queue.
 java.lang.Object peek()
          Like firstValue().
 java.lang.Object pop()
          Returns the first element of the queue and removes it (pops it).
 boolean popBoolean()
          pop() for boolean-values.
 double popDouble()
          pop() for double-values.
 float popFloat()
          pop() for float-values.
 int popInt()
          pop() for int-values.
 long popLong()
          pop() for long-values.
 void push(boolean b)
          push(java.lang.Object) for boolean-values.
 void push(double d)
          push(java.lang.Object) for double-values.
 void push(float f)
          push(java.lang.Object) for float-values.
 void push(int i)
          push(java.lang.Object) for int-values.
 void push(long l)
          push(java.lang.Object) for long-values.
 void push(java.lang.Object object)
          Appends an object to this queue.
 java.lang.String toString()
          Overrides java.lang.Object.toString().
 
Methods inherited from class gishur.core.BasicList
add, add, allowAccess, contains, copy, copy, copy, cut, cycle, cycle, enumerate, equals, find, findClass, findClosest, first, getDistance, getIndex, getListItem, getListItemArray, getListString, last, move, reconnect, reconnect, remove, requestAccess, reverse, storeInArray, toString, unconnect
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Empty constructor.
Method Detail

toString

public java.lang.String toString()
Overrides java.lang.Object.toString().
Overrides:
toString in class BasicList
See Also:
Object.toString()

clone

public java.lang.Object clone()
Implementation of Cloneable
clones the entire list by cloning the contained data-/keyobjects, if possible. If not possible, the references to the data-/keyobjects are maintained.
Specified by:
clone in interface Cloneable
Overrides:
clone in class java.lang.Object
Returns:
a clone of this object.
Throws:
InternalError - - if the Object could not be cloned properly
See Also:
Cloneable

clone

public java.lang.Object clone(java.util.Hashtable h,
                              int level)
clones the entire list according to ControlledCloneable. That means, all ListItems are cloned and connected proper.
For further details about level see also
Specified by:
clone in interface ControlledCloneable
Overrides:
clone in class BasicList
Parameters:
h - Hashtable to indicate which objects are already cloned
level - indicates how deep the objects should be cloned
Returns:
cloned object
Throws:
InternalError - - if the Object could not be cloned properly
See Also:
ControlledCloneable

length

public int length()
Returns the number of stored elements in this queue.
Overrides:
length in class BasicList
Returns:
number of elements

empty

public boolean empty()
Returns true, if the queue is empty.
Overrides:
empty in class BasicList
Returns:
true, if the queue is empty

contains

public boolean contains(java.lang.Object object)
Returns true, if object is stored in this Queue.
Parameters:
object - object to search for in the queue
Returns:
true, if object is stored in this Queue

firstValue

public java.lang.Object firstValue()
Returns the first element in the Queue. If the queue is empty, a ListException will be thrown.
Returns:
first element

lastValue

public java.lang.Object lastValue()
Returns the last element in the Queue. If the queue is empty, a ListException will be thrown.
Returns:
the queue's last element

peek

public java.lang.Object peek()
Like firstValue().
Returns:
first element
See Also:
peek()

push

public void push(java.lang.Object object)
Appends an object to this queue.
Parameters:
object - object to store

pop

public java.lang.Object pop()
Returns the first element of the queue and removes it (pops it).
Returns:
first element

clear

public void clear()
Clears the whole queue.
Overrides:
clear in class BasicList

convertToArray

public java.lang.Object[] convertToArray()
Converts this queue into an array.
Returns:
an array of objects

elements

public java.util.Enumeration elements()
Returns an java.util.Enumerator-object which enumerates all elements of this queue.
Returns:
an Enumeration enumerating all elements of this queue

getListView

public ListView getListView()
Creates and returns a ListView-object which enables full reading access to a BasicList wihtout knowing the explicite type.
Overrides:
getListView in class BasicList
Returns:
a ListView-object for full reading access

push

public void push(int i)
push(java.lang.Object) for int-values.
Parameters:
i - int-value to be pushed
See Also:
push(java.lang.Object)

push

public void push(long l)
push(java.lang.Object) for long-values.
Parameters:
i - long-value to be pushed
See Also:
push(java.lang.Object)

push

public void push(float f)
push(java.lang.Object) for float-values.
Parameters:
i - float-value to be pushed
See Also:
push(java.lang.Object)

push

public void push(double d)
push(java.lang.Object) for double-values.
Parameters:
i - double-value to be pushed
See Also:
push(java.lang.Object)

push

public void push(boolean b)
push(java.lang.Object) for boolean-values.
Parameters:
i - boolean-value to be pushed
See Also:
push(java.lang.Object)

popInt

public int popInt()
pop() for int-values. If the first object in the queue cannot be converted into an int, a ListException is thrown.
Returns:
the first element as an int
See Also:
pop()

popLong

public long popLong()
pop() for long-values. If the first object in the queue cannot be converted into a long, a ListException is thrown.
Returns:
the first element as a long
See Also:
pop()

popFloat

public float popFloat()
pop() for float-values. If the first object in the queue cannot be converted into a float, a ListException is thrown.
Returns:
the first element as a float
See Also:
pop()

popDouble

public double popDouble()
pop() for double-values. If the first object in the queue cannot be converted into a double, a ListException is thrown.
Returns:
the first element as a double
See Also:
pop()

popBoolean

public boolean popBoolean()
pop() for boolean-values. If the first object in the queue cannot be converted into a boolean, a ListException is thrown.
Returns:
the first element as a boolean
See Also:
pop()