com.sas.collection
Class Queue

com.sas.collection.Queue
All Implemented Interfaces:
java.io.Serializable

public class Queue
implements java.io.Serializable

A Queue is an object which refers to a linked list of objects that are placed at the end of the list when added, and removed from the beginning of the list when removed. Basically, a first in first out (FIFO) queue. The Queue class is synchronized and thus is thread safe.

See Also:
Pair, Serialized Form

Field Summary
protected  com.sas.collection.Pair _head
           
protected  long _size
           
protected  com.sas.collection.Pair _tail
           
 
Constructor Summary
Queue()
          Queue Constructor creates and instantiates the head and tail of the Queue class.
 
Method Summary
 void add(java.lang.Object info)
          Add places an object at the end of the queue.
 void clear()
          Clear removes all items from the queue and sets the size to zero.
 java.lang.Object dequeue()
          Removes and returns an object from the top of the queue.
 long getSize()
          Returns the current size of the queue.
protected  void init()
          init is used by the constructor and by the clear method to clear/initialize the head, tail, and size.
 boolean isEmpty()
          Tests if the head of the queue is pointing to the tail of the queue, if true, the queue is empty.
 

Field Detail

_head

protected com.sas.collection.Pair _head

_tail

protected com.sas.collection.Pair _tail

_size

protected long _size
Constructor Detail

Queue

public Queue()
Queue Constructor creates and instantiates the head and tail of the Queue class.

Method Detail

init

protected void init()
init is used by the constructor and by the clear method to clear/initialize the head, tail, and size.


clear

public void clear()
Clear removes all items from the queue and sets the size to zero.


add

public void add(java.lang.Object info)
Add places an object at the end of the queue.

Parameters:
info - any object

dequeue

public java.lang.Object dequeue()
Removes and returns an object from the top of the queue.

Returns:
Object the object at the top of the queue

isEmpty

public boolean isEmpty()
Tests if the head of the queue is pointing to the tail of the queue, if true, the queue is empty.

Returns:
boolean true if the queue is empty

getSize

public long getSize()
Returns the current size of the queue.

Returns:
int the current size of the queue



Copyright © 2009 SAS Institute Inc. All Rights Reserved.