org.fusesource.hawtdb.util
Class TreeMap<K,V>

java.lang.Object
  extended by org.fusesource.hawtdb.util.TreeMap<K,V>
All Implemented Interfaces:
java.io.Serializable

public class TreeMap<K,V>
extends java.lang.Object
implements java.io.Serializable

A TreeMap that is lighter weight than the Sun implementation with implementations for upper/lower/floor/ceiling accessors.

Author:
Hiram Chirino
See Also:
Serialized Form

Nested Class Summary
static class TreeMap.TreeEntry<K,V>
           
 
Constructor Summary
TreeMap()
           
TreeMap(java.util.Comparator<? super K> comparator)
           
 
Method Summary
 TreeMap.TreeEntry<K,V> ceilingEntry(K key)
          Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.
 void clear()
          Clears all elements in this map.
 java.util.Comparator<? super K> comparator()
           
 boolean containsKey(K key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
           
 TreeMap.TreeEntry<K,V> firstEntry()
          Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
 K firstKey()
           
 TreeMap.TreeEntry<K,V> floorEntry(K key)
          Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.
 V get(K key)
           
 TreeMap.TreeEntry<K,V> getEntry(K key)
           
 boolean isEmpty()
           
 java.util.Set<K> keySet()
           
 TreeMap.TreeEntry<K,V> lastEntry()
          Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
 K lastKey()
           
 TreeMap.TreeEntry<K,V> lowerEntry(K key)
          Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key
 V put(K key, V value)
           
 void putAll(java.util.Map<? extends K,? extends V> t)
           
 V remove(K key)
           
 V removeEntry(TreeMap.TreeEntry<K,V> n)
          complicated red-black delete stuff.
 int size()
           
 TreeMap.TreeEntry<K,V> upperEntry(K key)
          Returns a key-value mapping associated with the lowest key strictly greater than the given key, or null if there is no such key
 java.util.Collection<V> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeMap

public TreeMap()

TreeMap

public TreeMap(java.util.Comparator<? super K> comparator)
Method Detail

comparator

public java.util.Comparator<? super K> comparator()

firstKey

public K firstKey()
Returns:
The first key in the map.

lastKey

public K lastKey()
Returns:
The last key in the map.

clear

public void clear()
Clears all elements in this map.


containsKey

public boolean containsKey(K key)

containsValue

public boolean containsValue(java.lang.Object value)

entrySet

public java.util.Set<java.util.Map.Entry<K,V>> entrySet()

get

public V get(K key)

getEntry

public final TreeMap.TreeEntry<K,V> getEntry(K key)

firstEntry

public TreeMap.TreeEntry<K,V> firstEntry()
Returns a key-value mapping associated with the least key in this map, or null if the map is empty.

Returns:
The lowest key in the map

lastEntry

public TreeMap.TreeEntry<K,V> lastEntry()
Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.

Returns:
The entry associated with the greates key in the map.

lowerEntry

public TreeMap.TreeEntry<K,V> lowerEntry(K key)
Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key

Parameters:
key - the key.
Returns:

floorEntry

public TreeMap.TreeEntry<K,V> floorEntry(K key)
Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.

Parameters:
key - The key for which to search.
Returns:
a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.

upperEntry

public TreeMap.TreeEntry<K,V> upperEntry(K key)
Returns a key-value mapping associated with the lowest key strictly greater than the given key, or null if there is no such key

Parameters:
key - The key
Returns:
a key-value mapping associated with the lowest key strictly greater than the given key

ceilingEntry

public TreeMap.TreeEntry<K,V> ceilingEntry(K key)
Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.

Parameters:
key -
Returns:

isEmpty

public boolean isEmpty()

keySet

public java.util.Set<K> keySet()

putAll

public void putAll(java.util.Map<? extends K,? extends V> t)

remove

public V remove(K key)

put

public V put(K key,
             V value)

removeEntry

public final V removeEntry(TreeMap.TreeEntry<K,V> n)
complicated red-black delete stuff. Based on Apache Common's TreeBidiMap

Parameters:
n - the node to be deleted

size

public int size()

values

public java.util.Collection<V> values()


Copyright © 2009-2011 FuseSource, Corp.. All Rights Reserved.