org.jfree.report.util
Class KeyedQueue

java.lang.Object
  extended byorg.jfree.report.util.KeyedQueue
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class KeyedQueue
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A keyed queue is a hashtable like structure which will store a certain number of elements. If the defined element size is exceeded, the firstly stored element gets removed.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
KeyedQueue()
          Creates a KeyedQueue with an initial limit of 10 items.
KeyedQueue(int limit)
          Creates a KeyedQueue with an initial limit if limit items.
 
Method Summary
 void clear()
          Removes all elements in the queue.
 java.lang.Object clone()
          Clones the queue.
 java.lang.Object get(java.lang.Object key)
          Queries the queue for the value stored under the given key.
 int getLimit()
          Returns the maximum number of elements in the queue.
 void put(java.lang.Object key, java.lang.Object ob)
          Adds a new key/value pair to the queue.
 void remove(java.lang.Object key)
          Removes the entry stored under the given key.
 void removeLast()
          Removes the last element in the queue.
 void setLimit(int limit)
          Defines the maximal number of elements in the queue.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyedQueue

public KeyedQueue()
Creates a KeyedQueue with an initial limit of 10 items.


KeyedQueue

public KeyedQueue(int limit)
Creates a KeyedQueue with an initial limit if limit items.

Parameters:
limit - the maximum number of items.
Method Detail

setLimit

public void setLimit(int limit)
Defines the maximal number of elements in the queue.

Parameters:
limit - the maximum number of items.

getLimit

public int getLimit()
Returns the maximum number of elements in the queue.

Returns:
the maximum number of elements in the queue.

put

public void put(java.lang.Object key,
                java.lang.Object ob)
Adds a new key/value pair to the queue. If the pair is already contained in the list, it is moved to the first position so that is gets removed last.

Parameters:
key - the key.
ob - the value.

get

public java.lang.Object get(java.lang.Object key)
Queries the queue for the value stored under the given key.

Parameters:
key - the key.
Returns:
the value.

remove

public void remove(java.lang.Object key)
Removes the entry stored under the given key.

Parameters:
key - the key.

removeLast

public void removeLast()
Removes the last element in the queue.


clear

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


clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones the queue.

Returns:
a clone.
Throws:
java.lang.CloneNotSupportedException - this should never happen.