anthill.util
Class TreeList

java.lang.Object
  |
  +--anthill.util.MapList
        |
        +--anthill.util.TreeList
All Implemented Interfaces:
Clearable, Map, Runnable, Serializable

public class TreeList
extends MapList
implements Serializable

This class implements a TreeList, which is a combination of a TreeMap and a doubly linked list. The linked listed is always in sorted order according to the least recently used (LRU) scheme, while the TreeMap is sorted according to the keys of the map.

Version:
$Revision: 1.12 $
Author:
Hein Meling
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class anthill.util.MapList
MapList.Entry
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Field Summary
static int MAX_VALUES
          Maximum number of values to be returned from the get(key, valcnt) method
protected  SortedMap proxyMap
          A proxy for the actual map, used to access methods from the SortedMap interface.
 
Fields inherited from class anthill.util.MapList
map
 
Constructor Summary
TreeList(int maxsize)
          Instantiate a new TreeList object by setting the maximum number of key, value pairs which may be contained in it.
TreeList(int maxsize, int maxtime)
          Instantiate a new TreeList object by setting the maximum number of key, value pairs which may be contained in it.
 
Method Summary
 Object[] get(Object key, int valuecount)
          Returns a set of object values whose keys closely match that of the provided key.
 
Methods inherited from class anthill.util.MapList
add, clear, containsKey, containsValue, end, entrySet, get, getHeadKey, getMaxsize, getMaxtime, isEmpty, keyList, keySet, put, putAll, remove, removeChunck, run, setMaxsize, setMaxtime, size, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

MAX_VALUES

public static final int MAX_VALUES
Maximum number of values to be returned from the get(key, valcnt) method

See Also:
Constant Field Values

proxyMap

protected SortedMap proxyMap
A proxy for the actual map, used to access methods from the SortedMap interface.

Constructor Detail

TreeList

public TreeList(int maxsize,
                int maxtime)
Instantiate a new TreeList object by setting the maximum number of key, value pairs which may be contained in it.

Parameters:
maxsize - Maximum number of objects which may be contained in this TreeList. If zero, there is no upper limit to the the size.

TreeList

public TreeList(int maxsize)
Instantiate a new TreeList object by setting the maximum number of key, value pairs which may be contained in it.

Parameters:
maxsize - Maximum number of objects which may be contained in this TreeList. If zero, there is no upper limit to the the size.
Method Detail

get

public Object[] get(Object key,
                    int valuecount)
Returns a set of object values whose keys closely match that of the provided key. The valuecount specifies how may values close to the key should be returned. If not enough keys/values can be found, a null entry is returned in the remaining positions in the returned array.

Note that the valuecount is bounded within MAX_VALUES.

Parameters:
key - key whose closely associated values is to be returned. The provided key must implement the Closeness interface to facilitate the proximity comparision.
valuecount - how many values to return.
Returns:
value set matching or closely matching the specified key.