rice.p2p.util
Class ReverseTreeMap

java.lang.Object
  extended by rice.p2p.util.ReverseTreeMap
All Implemented Interfaces:
Serializable

public class ReverseTreeMap
extends Object
implements Serializable

Version:
$Id: ReverseTreeMap.java 4654 2009-01-08 16:33:07Z jeffh $
Author:
Alan Mislove
See Also:
Serialized Form

Field Summary
protected  SortedMap normal
          The internal normal map
protected  SortedMap nulls
          The internal list of keys with null as a mapping
protected  SortedMap reverse
          The internal value -> list of keys map
 
Constructor Summary
  ReverseTreeMap()
          Constructor
protected ReverseTreeMap(SortedMap normal, SortedMap reverse, SortedMap nulls)
          Constructor
 
Method Summary
 boolean containsKey(Object key)
          Returns whether or not we contain the key
protected  SortedMap convert(SortedMap map)
          Internal method which converts a sortedmap to an iterator
 Object get(Object key)
          Returns the value associated with the given key
 SortedMap keyHeadMap(Object value)
          Method which returns a *cloned* head map, or all of the values up to the specified value
 SortedMap keyMap()
          Method which returns the key map
 Set keySet()
          Return the set of keys
 SortedMap keySubMap(Object start, Object end)
          Method which returns a *cloned* sub map, or all of the values between the specified values
 SortedMap keyTailMap(Object value)
          Method which returns a *cloned* tail map, or all of the values after a the specified value
 void put(Object key, Object value)
          Method which caputures the insert and adds it to the reverse map
 void remove(Object key)
          Removes any and all mappings with the given key
 int size()
          returns the size
 SortedMap valueHeadMap(Object value)
          Method which returns a headset of the values, or all the keys with values up to the specified value
 SortedMap valueNullMap()
          Method which returns all of the keys which have null values
 SortedMap valueSubMap(Object start, Object end)
          Method which returns a headset of the values, or all the keys with values up to the specified value
 SortedMap valueTailMap(Object value)
          Method which returns a tailset of the values, or all the keys with values after to the specified value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

normal

protected SortedMap normal
The internal normal map


reverse

protected SortedMap reverse
The internal value -> list of keys map


nulls

protected SortedMap nulls
The internal list of keys with null as a mapping

Constructor Detail

ReverseTreeMap

public ReverseTreeMap()
Constructor


ReverseTreeMap

protected ReverseTreeMap(SortedMap normal,
                         SortedMap reverse,
                         SortedMap nulls)
Constructor

Method Detail

size

public int size()
returns the size

Returns:
the size

containsKey

public boolean containsKey(Object key)
Returns whether or not we contain the key

Parameters:
key - THe key
Returns:
Whether or not we have it

get

public Object get(Object key)
Returns the value associated with the given key

Parameters:
key - The key
Returns:
The value

keySet

public Set keySet()
Return the set of keys

Returns:
The set of keys

remove

public void remove(Object key)
Removes any and all mappings with the given key

Parameters:
key - The key

put

public void put(Object key,
                Object value)
Method which caputures the insert and adds it to the reverse map

Parameters:
key - The key
value - The value

keyMap

public SortedMap keyMap()
Method which returns the key map


keyHeadMap

public SortedMap keyHeadMap(Object value)
Method which returns a *cloned* head map, or all of the values up to the specified value

Parameters:
value - The start value
Returns:
a head map

keyTailMap

public SortedMap keyTailMap(Object value)
Method which returns a *cloned* tail map, or all of the values after a the specified value

Parameters:
value - The start value
Returns:
a head map

keySubMap

public SortedMap keySubMap(Object start,
                           Object end)
Method which returns a *cloned* sub map, or all of the values between the specified values

Parameters:
start - The start value
end - The end value
Returns:
a head map

valueHeadMap

public SortedMap valueHeadMap(Object value)
Method which returns a headset of the values, or all the keys with values up to the specified value

Parameters:
value - The maximal value

valueTailMap

public SortedMap valueTailMap(Object value)
Method which returns a tailset of the values, or all the keys with values after to the specified value

Parameters:
value - The minimal value

valueSubMap

public SortedMap valueSubMap(Object start,
                             Object end)
Method which returns a headset of the values, or all the keys with values up to the specified value

Parameters:
value - The maximal value

valueNullMap

public SortedMap valueNullMap()
Method which returns all of the keys which have null values


convert

protected SortedMap convert(SortedMap map)
Internal method which converts a sortedmap to an iterator

Parameters:
map - THe map to convert
Returns:
The converted map


Copyright © 2010. All Rights Reserved.