org.egothor.cache.fifo
Class FifoList<T>

java.lang.Object
  extended by org.egothor.cache.fifo.FifoList<T>
Type Parameters:
T - items stored in the list
All Implemented Interfaces:
List<T>
Direct Known Subclasses:
LruList

public class FifoList<T>
extends java.lang.Object
implements List<T>

Represents a FIFO (First-In First-Out) list.


Constructor Summary
FifoList(int intendedCapacity)
          Constructor for the FifoList object.
 
Method Summary
 boolean add(T entry)
          Adds an item to the list.
 void clear()
          Removes all items from the list.
 boolean contains(T entry)
          Checks whether an item is present in the list.
 T getNewest()
          Gets the item that has been the shortest time in the list.
 T getOldest()
          Gets the item that has been the longest time in the list.
 boolean remove(T entry)
          Removes an item from the list.
 int size()
          Returns the number of items stored in the list.
 java.lang.String toString()
          Returns a text representation of the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FifoList

public FifoList(int intendedCapacity)
Constructor for the FifoList object.

Parameters:
intendedCapacity - maximum number of items this list can hold (but can be exceeded whenever needed)
Method Detail

getOldest

public T getOldest()
Gets the item that has been the longest time in the list.

Specified by:
getOldest in interface List<T>
Returns:
the oldest item

getNewest

public T getNewest()
Gets the item that has been the shortest time in the list.

Specified by:
getNewest in interface List<T>
Returns:
the newest item

add

public boolean add(T entry)
Adds an item to the list.

Specified by:
add in interface List<T>
Parameters:
entry - item to add to the list
Returns:
true, if the item was successfully added to list, false otherwise

remove

public boolean remove(T entry)
Removes an item from the list.

Specified by:
remove in interface List<T>
Parameters:
entry - item to remove from the list
Returns:
true, if the item was successfully removed from list, false otherwise

contains

public boolean contains(T entry)
Checks whether an item is present in the list.

Specified by:
contains in interface List<T>
Parameters:
entry - item to check
Returns:
true, if the item is in the list, false otherwise

clear

public void clear()
Removes all items from the list.

Specified by:
clear in interface List<T>

size

public int size()
Returns the number of items stored in the list.

Specified by:
size in interface List<T>
Returns:
number of items stored

toString

public java.lang.String toString()
Returns a text representation of the list.

Overrides:
toString in class java.lang.Object
Returns:
text representation of the list