com.planet_ink.coffee_mud.core.collections
Class KeyPairSearchTree<V>

java.lang.Object
  extended by com.planet_ink.coffee_mud.core.collections.KeyPairSearchTree<V>
Direct Known Subclasses:
KeyPairWildSearchTree

public class KeyPairSearchTree<V>
extends java.lang.Object

A quick prefix lookup tree that takes a lot of memory, but is worth it in speed. It stores key/pairs, and can be asked if a string starts with one of the keys. If it does, it returns the value of the pair.


Nested Class Summary
protected  class KeyPairSearchTree.KeyPairNode<K,T>
           
 
Field Summary
protected  KeyPairSearchTree.KeyPairNode<java.lang.String,V> root
           
 
Constructor Summary
KeyPairSearchTree()
           
 
Method Summary
 void addEntry(java.lang.String key, V value)
          Store a new key/value pair
 Pair<java.lang.String,V> findLongestValue(java.lang.String fullStr)
          Retrieve teh value for the longest key that the given string starts with
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected KeyPairSearchTree.KeyPairNode<java.lang.String,V> root
Constructor Detail

KeyPairSearchTree

public KeyPairSearchTree()
Method Detail

addEntry

public void addEntry(java.lang.String key,
                     V value)
Store a new key/value pair

Parameters:
key - the key to add
value - the value of the key

findLongestValue

public Pair<java.lang.String,V> findLongestValue(java.lang.String fullStr)
Retrieve teh value for the longest key that the given string starts with

Parameters:
fullStr - the string that might start with a key
Returns:
the value