de.tomshut.util
Class LatinTrieNode<T>

java.lang.Object
  extended by de.tomshut.util.LatinTrieNode<T>
All Implemented Interfaces:
java.lang.Comparable<java.util.Map.Entry<java.lang.CharSequence,T>>, java.util.Map.Entry<java.lang.CharSequence,T>

public final class LatinTrieNode<T>
extends java.lang.Object
implements java.util.Map.Entry<java.lang.CharSequence,T>, java.lang.Comparable<java.util.Map.Entry<java.lang.CharSequence,T>>


Constructor Summary
LatinTrieNode()
           
 
Method Summary
 int compareTo(java.util.Map.Entry<java.lang.CharSequence,T> o)
           
 java.util.Set<java.util.Map.Entry<java.lang.CharSequence,T>> entrySet()
          Returns a Set view of the child nodes of this trie node.
 boolean equals(java.lang.Object obj)
          Compares the specified object with this entry for equality.
 java.lang.CharSequence getKey()
          Returns the key corresponding to this entry.
 T getValue()
          Returns the value corresponding to this entry.
 int hashCode()
          Returns the hash code of the key if key is not null.
 boolean isEmpty()
          Checks if this node doesn't contain a key and has no children
 boolean isValid()
          Check if our node is valid.
 java.util.Set<java.lang.CharSequence> keySet()
          Returns a Set view of the keys of the child nodes of this trie node.
 T setValue(T value)
          Replaces the value corresponding to this entry with the specified value (optional operation).
 java.lang.String toDebugString()
           
 java.lang.String toString()
           
 java.util.Collection<T> values()
          Returns a Collection view of the values contained in the child nodes of this trie node.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LatinTrieNode

public LatinTrieNode()
Method Detail

isEmpty

public final boolean isEmpty()
Checks if this node doesn't contain a key and has no children

Returns:
true if the node is empty, false otherwise

isValid

public final boolean isValid()
Check if our node is valid. The LatinTrie should never return invalid nodes

Returns:
true if the node has children and/or a key.

getKey

public final java.lang.CharSequence getKey()
Returns the key corresponding to this entry.

Specified by:
getKey in interface java.util.Map.Entry<java.lang.CharSequence,T>
Returns:
the key corresponding to this entry.

getValue

public final T getValue()
Returns the value corresponding to this entry. If the node has been removed from the backing trie, the results of this call are undefined.

Specified by:
getValue in interface java.util.Map.Entry<java.lang.CharSequence,T>
Returns:
the value corresponding to this entry.

setValue

public final T setValue(T value)
Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the trie.) The behavior of this call is undefined if the node has already been removed from the trie.

Specified by:
setValue in interface java.util.Map.Entry<java.lang.CharSequence,T>
Parameters:
value - new value to be stored in this entry
Returns:
old value corresponding to the entry

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object

toDebugString

public final java.lang.String toDebugString()

hashCode

public final int hashCode()
Returns the hash code of the key if key is not null. Returns an arbitrary value otherwise.

Specified by:
hashCode in interface java.util.Map.Entry<java.lang.CharSequence,T>
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code;

equals

public final boolean equals(java.lang.Object obj)
Compares the specified object with this entry for equality. Returns true if the given object is also a trie node and the two nodes represent the same key and value.

Specified by:
equals in interface java.util.Map.Entry<java.lang.CharSequence,T>
Overrides:
equals in class java.lang.Object
Parameters:
obj - object to be compared for equality with this trie node
Returns:
true if the specified object is equal to this trie node

compareTo

public final int compareTo(java.util.Map.Entry<java.lang.CharSequence,T> o)
Specified by:
compareTo in interface java.lang.Comparable<java.util.Map.Entry<java.lang.CharSequence,T>>

entrySet

public final java.util.Set<java.util.Map.Entry<java.lang.CharSequence,T>> entrySet()
Returns a Set view of the child nodes of this trie node. Only nodes that contain keys are returned. A new HashSet is created, so changes to the trie are not reflected in the set, and vice-versa.

Returns:
a set view of the child nodes of this trie.

keySet

public final java.util.Set<java.lang.CharSequence> keySet()
Returns a Set view of the keys of the child nodes of this trie node. Only nodes that contain keys are returned. A new HashSet is created, so changes to the trie are not reflected in the set, and vice-versa.

Returns:
a Set view of the keys of the child nodes of this trie node.

values

public final java.util.Collection<T> values()
Returns a Collection view of the values contained in the child nodes of this trie node. Only nodes that contain keys are returned. A new ArrayList is created, so changes to the trie are not reflected in the collection, and vice-versa.

Returns:
a Collection view of the values contained in the child nodes of this trie node.