gov.nist.antd.java.util
Class RingList

java.lang.Object
  |
  +--gov.nist.antd.java.util.RingList

public class RingList
extends java.lang.Object

This class represents a ring list.

 This class was developed at the National Institute of Standards and
 Technology by employees of the Federal Government in the course of
 their official duties. Pursuant to title 17 Section 105 of the United
 States Code this software is not subject to copyright protection and
 is in the public domain.
NIST assumes no responsibility whatsoever for its use by other parties, and makes no guarantees, expressed or implied, about its quality, reliability, or any other characteristic.
We would appreciate acknowledgement if the software is used.
NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.

Author:
borchert
, rouil

Field Summary
private  java.lang.Object lastSelected
          The last selected Object in the list.
private  java.util.LinkedList list
          The list that is used to simulate the ring.
 
Constructor Summary
RingList()
          Creates a ring list out of a Vector.
 
Method Summary
 void add(java.lang.Object obj)
          Adds an object to the end of a ring.
 void clear()
          Clears the whole ring.
 java.lang.Object get(java.lang.Object obj)
          Returns the given element if existent and set the internal pointer to the requested object.
 java.lang.Object getFirst()
          Returns the object, specified as first object in the ring.
private  java.lang.Object getLast()
          Returns the object, specified as last object in the ring.
 java.lang.Object getNext()
          Returns the next object in the ring.
 java.lang.Object getPrevious()
          Returns the next object in the ring.
 void insertFirst(java.lang.Object o)
          Inserts an object to the ring at the first position.
static void main(java.lang.String[] argv)
           
 void remove(java.lang.Object obj)
          Removed the element out of the ring.
 java.lang.String toString()
          Creates a representative string output of the RingList.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

list

private java.util.LinkedList list
The list that is used to simulate the ring.


lastSelected

private java.lang.Object lastSelected
The last selected Object in the list.

Constructor Detail

RingList

public RingList()
Creates a ring list out of a Vector.

Method Detail

getFirst

public java.lang.Object getFirst()
Returns the object, specified as first object in the ring.

Returns:
The starting element in the ring.

getLast

private java.lang.Object getLast()
Returns the object, specified as last object in the ring.

Returns:
The last element in the ring.

getNext

public java.lang.Object getNext()
Returns the next object in the ring.

Returns:
The next element in the ring.

getPrevious

public java.lang.Object getPrevious()
Returns the next object in the ring.

Returns:
The next element in the ring.

get

public java.lang.Object get(java.lang.Object obj)
Returns the given element if existent and set the internal pointer to the requested object. It the object does not exist, the internal pointer is resetted to null and null will be returned.

Parameters:
obj - the requested object.
Returns:
The requested object or null.

add

public void add(java.lang.Object obj)
Adds an object to the end of a ring.


insertFirst

public void insertFirst(java.lang.Object o)
Inserts an object to the ring at the first position.

Parameters:
o - The element.

remove

public void remove(java.lang.Object obj)
Removed the element out of the ring.


clear

public void clear()
Clears the whole ring.


toString

public java.lang.String toString()
Creates a representative string output of the RingList.

Overrides:
toString in class java.lang.Object
Returns:
Th eString representation.

main

public static void main(java.lang.String[] argv)