j3d.org Code

org.j3d.util
Class Queue

java.lang.Object
  extended by org.j3d.util.Queue

public class Queue
extends java.lang.Object

Simple 'First In First Out' (FIFO) queue. Backend is implemented with a Collections LinkedList.

This simple queue does not block if you request an item. If nothing is in the queue then it just returns you a null value.

Taken from the VLC common code library http://www.vlc.com.au/common/ This softare is released under the GNU LGPL

Version:
$Revision: 1.1 $
Author:
Justin Couch.
See Also:
LinkedList

Constructor Summary
Queue()
          Constructor.
 
Method Summary
 void add(java.lang.Object o)
          Add an element to the end of the queue.
 void clear()
          Remove all elements in the queue.
 java.lang.Object getNext()
          Return the next element from the front and remove it from the queue.
 boolean hasNext()
          Check if queue has more elements.
 java.lang.Object peekNext()
          Return the next element from the front of the queue.
 void remove(java.lang.Object obj)
          Remove the given item from the list.
 int size()
          Return the number of elements in the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Constructor. Create a simple queue.

Method Detail

add

public void add(java.lang.Object o)
Add an element to the end of the queue.

Parameters:
o - Element to add.

getNext

public java.lang.Object getNext()
Return the next element from the front and remove it from the queue.

Returns:
element at the from of the queue, or null if empty.

peekNext

public java.lang.Object peekNext()
Return the next element from the front of the queue.

Returns:
element at the from of the queue, or null if empty.

hasNext

public boolean hasNext()
Check if queue has more elements.

Returns:
true if queue has more elements.

remove

public void remove(java.lang.Object obj)
Remove the given item from the list. If it is not in the queue it will silently ignore the request.

Parameters:
obj - The object to remove

size

public int size()
Return the number of elements in the queue.

Returns:
size of queue.

clear

public void clear()
Remove all elements in the queue.


j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org