org.rutil.collection.trie
Class TrieNode<VALUE_TYPE>

java.lang.Object
  extended by org.rutil.collection.SingleLinkedEntry.DefaultSingleLinkedEntry<VALUE_TYPE>
      extended by org.rutil.collection.trie.TrieNode<VALUE_TYPE>
All Implemented Interfaces:
SingleLinkedEntry<VALUE_TYPE>

public class TrieNode<VALUE_TYPE>
extends SingleLinkedEntry.DefaultSingleLinkedEntry<VALUE_TYPE>

A node object that can be used to build a tree of nodes. A node is organized as a node (itself) with other nodes as branches (optional). A key and (optionally) one or more value can be associated with each node.

Author:
mohan

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.rutil.collection.SingleLinkedEntry
SingleLinkedEntry.DefaultSingleLinkedEntry<T>
 
Constructor Summary
TrieNode()
           
 
Method Summary
 TrieNode<VALUE_TYPE> add(java.lang.String key, VALUE_TYPE value)
           
protected  void addChars(java.lang.String key, int startIndex)
           
protected  TrieNode<VALUE_TYPE> addKey(java.lang.String key, int index)
           
protected  TrieNode<VALUE_TYPE> addNewNode(java.lang.String key, int index)
           
 void addNode(TrieNode<VALUE_TYPE> node)
           
protected  void addValue(VALUE_TYPE value)
           
protected  boolean areAllCharsPartOfKey(java.lang.String key, int index)
           
 TrieNode<VALUE_TYPE> branch(int branchFrom)
           
 TrieNode<VALUE_TYPE> findNode(char c)
           
 CharArrayList getChars()
           
 char getFirstChar()
           
 int getLastMatchingCharIndex(java.lang.String key, int startIndex)
           
 java.util.Iterator<TrieNode<VALUE_TYPE>> getNodes()
           
 java.util.Iterator<VALUE_TYPE> getValues()
           
 boolean hasChildNodes()
           
 boolean hasValues()
           
protected  boolean isEmpty()
           
 SingleLinkedList<VALUE_TYPE> remove(java.lang.String key)
           
 boolean startsWithChar(char c)
           
 
Methods inherited from class org.rutil.collection.SingleLinkedEntry.DefaultSingleLinkedEntry
getNext, getValue, setNext, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrieNode

public TrieNode()
Method Detail

add

public TrieNode<VALUE_TYPE> add(java.lang.String key,
                                VALUE_TYPE value)

addKey

protected TrieNode<VALUE_TYPE> addKey(java.lang.String key,
                                      int index)

areAllCharsPartOfKey

protected boolean areAllCharsPartOfKey(java.lang.String key,
                                       int index)

findNode

public TrieNode<VALUE_TYPE> findNode(char c)

addNewNode

protected TrieNode<VALUE_TYPE> addNewNode(java.lang.String key,
                                          int index)

getNodes

public java.util.Iterator<TrieNode<VALUE_TYPE>> getNodes()

hasChildNodes

public boolean hasChildNodes()

addChars

protected void addChars(java.lang.String key,
                        int startIndex)

addNode

public void addNode(TrieNode<VALUE_TYPE> node)

addValue

protected void addValue(VALUE_TYPE value)

hasValues

public boolean hasValues()

getValues

public java.util.Iterator<VALUE_TYPE> getValues()

getChars

public CharArrayList getChars()

isEmpty

protected boolean isEmpty()

getLastMatchingCharIndex

public int getLastMatchingCharIndex(java.lang.String key,
                                    int startIndex)

branch

public TrieNode<VALUE_TYPE> branch(int branchFrom)

startsWithChar

public boolean startsWithChar(char c)

getFirstChar

public char getFirstChar()

remove

public SingleLinkedList<VALUE_TYPE> remove(java.lang.String key)