com.jaxfront.core.util
Class RollingList

java.lang.Object
  extended by com.jaxfront.core.util.RollingList
Type Parameters:
T - The type if items that this list contains

public class RollingList
extends java.lang.Object

Implements a "rolling list". A rolling list has a maximum capacity, and removes the oldest elements from the list to maintain this capacity.


Constructor Summary
RollingList(int capacity)
          Creates a new RollingList of the specified capacity.
RollingList(int capacity, boolean rolingGet)
           
RollingList(int capacity, java.lang.Object empty)
          Creates a new RollingList of the specified capacity, with the specified "empty" element appended to the end.
RollingList(java.util.List rolingItems, boolean rolingGet)
           
RollingList(java.lang.Object[] rolingItems, boolean rolingGet)
           
 
Method Summary
 boolean add(java.lang.Object e)
          Adds the specified item to this list.
 void append(int pos, java.lang.Object e)
          Append the specified item to this list.
 void append(java.lang.Object e)
          Append the specified item to this list.
 void clear()
          Clears all items from this list.
 boolean contains(java.lang.Object o)
          Determines if this list contains the specified object.
 java.lang.Object get(int index)
          Retrieves the item at the specified index in this list.
 java.lang.Object getCurrent()
           
 java.util.List getList()
          Retrieves a list of items that this rolling list contains.
 java.lang.Object getNext()
          Retrieves the element after the positional pointer of the list.
 int getPosition()
          Retrieves the current position within the list.
 java.lang.Object getPrevious()
          Retrieves the element before the positional pointer of the list.
 boolean hasNext()
          Determines if there is an element after the positional pointer of the list.
 boolean hasPrevious()
          Determines if there is an element befpre the positional pointer of the list.
 boolean isEmpty()
          Determines if this list is currently empty.
static void main(java.lang.String[] args)
           
 boolean remove(java.lang.Object o)
          Removes the specified element from this list.
 void rollingGet(boolean rollingGet)
           
 void seekTo(java.lang.Object o)
           
 void seekToEnd()
          Sets the positional pointer of this list to the end.
 void seekToStart()
          Sets the positional pointer of this list to the start.
 void setPosition(int position)
          Sets the positional pointer of this list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RollingList

public RollingList(int capacity)
Creates a new RollingList of the specified capacity.

Parameters:
capacity - The capacity of this list.

RollingList

public RollingList(int capacity,
                   boolean rolingGet)

RollingList

public RollingList(int capacity,
                   java.lang.Object empty)
Creates a new RollingList of the specified capacity, with the specified "empty" element appended to the end.

Parameters:
capacity - The capacity of this list.
empty - The "empty" element to be added

RollingList

public RollingList(java.util.List rolingItems,
                   boolean rolingGet)

RollingList

public RollingList(java.lang.Object[] rolingItems,
                   boolean rolingGet)
Method Detail

add

public boolean add(java.lang.Object e)
Adds the specified item to this list. If the list has reached its maximum capacity, this method will remove elements from the start of the list until there is sufficient room for the new element.

Parameters:
e - The element to be added to the list.
Returns:
True

append

public void append(int pos,
                   java.lang.Object e)
Append the specified item to this list.

Parameters:
e - The element to be added to the list.

append

public void append(java.lang.Object e)
Append the specified item to this list.

Parameters:
e - The element to be added to the list.

clear

public void clear()
Clears all items from this list.


contains

public boolean contains(java.lang.Object o)
Determines if this list contains the specified object.

Parameters:
o - The object to be checked
Returns:
True if this list contains the item, false otherwise.

get

public java.lang.Object get(int index)
Retrieves the item at the specified index in this list.

Parameters:
index - The index to look up
Returns:
The item at the specified index

getCurrent

public java.lang.Object getCurrent()

getList

public java.util.List getList()
Retrieves a list of items that this rolling list contains.

Returns:
A list of items in this rolling list.

getNext

public java.lang.Object getNext()
Retrieves the element after the positional pointer of the list.

Returns:
The next element in the list

getPosition

public int getPosition()
Retrieves the current position within the list.

Returns:
This list's positional pointer

getPrevious

public java.lang.Object getPrevious()
Retrieves the element before the positional pointer of the list.

Returns:
The previous element in the list

hasNext

public boolean hasNext()
Determines if there is an element after the positional pointer of the list.

Returns:
True if there is an element, false otherwise.

hasPrevious

public boolean hasPrevious()
Determines if there is an element befpre the positional pointer of the list.

Returns:
True if there is an element, false otherwise.

isEmpty

public boolean isEmpty()
Determines if this list is currently empty.

Returns:
True if the list is empty, false otherwise.

main

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

remove

public boolean remove(java.lang.Object o)
Removes the specified element from this list.

Parameters:
o - The object to be removed from the list.
Returns:
True if the list contained the specified element, false otherwise.

rollingGet

public void rollingGet(boolean rollingGet)

seekTo

public void seekTo(java.lang.Object o)

seekToEnd

public void seekToEnd()
Sets the positional pointer of this list to the end.


seekToStart

public void seekToStart()
Sets the positional pointer of this list to the start.


setPosition

public void setPosition(int position)
Sets the positional pointer of this list.

Parameters:
position - The new position