org.javimmutable.collections.tree
Class ThreeNode<K,V>

java.lang.Object
  extended by org.javimmutable.collections.tree.TreeNode<K,V>
      extended by org.javimmutable.collections.tree.ThreeNode<K,V>
All Implemented Interfaces:
Cursorable<JImmutableMap.Entry<K,V>>

@Immutable
public class ThreeNode<K,V>
extends TreeNode<K,V>


Constructor Summary
ThreeNode(TreeNode<K,V> left, TreeNode<K,V> middle, TreeNode<K,V> right, K leftMaxKey, K middleMaxKey, K rightMaxKey)
           
 
Method Summary
 void addEntriesTo(Collection<JImmutableMap.Entry<K,V>> collection)
          Adds this node's value and all of its children's value to the collection.
 Cursor<JImmutableMap.Entry<K,V>> cursor()
          Returns a Cursor visiting all entries in sorted order.
 boolean equals(Object o)
           
 Holder<V> find(Comparator<K> comparator, K key)
          Return a (possibly empty) Holder containing the value matching key.
 Holder<JImmutableMap.Entry<K,V>> findEntry(Comparator<K> comparator, K key)
          Return a (possibly empty) Holder containing the an Entry matching key.
 TreeNode<K,V> getLeft()
           
 K getLeftMaxKey()
           
 TreeNode<K,V> getMiddle()
           
 K getMiddleMaxKey()
           
 TreeNode<K,V> getRight()
           
 K getRightMaxKey()
           
 V getValueOr(Comparator<K> comparator, K key, V defaultValue)
          Return the value matching key or defaultValue if no match is found.
 int hashCode()
           
 String toString()
           
 int verifyDepthsMatch()
           
 
Methods inherited from class org.javimmutable.collections.tree.TreeNode
assign, delete, isEmpty, of
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreeNode

public ThreeNode(TreeNode<K,V> left,
                 TreeNode<K,V> middle,
                 TreeNode<K,V> right,
                 K leftMaxKey,
                 K middleMaxKey,
                 K rightMaxKey)
Method Detail

getValueOr

public V getValueOr(Comparator<K> comparator,
                    K key,
                    V defaultValue)
Description copied from class: TreeNode
Return the value matching key or defaultValue if no match is found. Searches this node and its appropriate children.

Specified by:
getValueOr in class TreeNode<K,V>
Returns:

find

public Holder<V> find(Comparator<K> comparator,
                      K key)
Description copied from class: TreeNode
Return a (possibly empty) Holder containing the value matching key. Searches this node and its appropriate children.

Specified by:
find in class TreeNode<K,V>
Returns:

findEntry

public Holder<JImmutableMap.Entry<K,V>> findEntry(Comparator<K> comparator,
                                                  K key)
Description copied from class: TreeNode
Return a (possibly empty) Holder containing the an Entry matching key. Searches this node and its appropriate children.

Specified by:
findEntry in class TreeNode<K,V>
Returns:

addEntriesTo

public void addEntriesTo(Collection<JImmutableMap.Entry<K,V>> collection)
Description copied from class: TreeNode
Adds this node's value and all of its children's value to the collection.

Specified by:
addEntriesTo in class TreeNode<K,V>

verifyDepthsMatch

public int verifyDepthsMatch()

getLeft

public TreeNode<K,V> getLeft()

getMiddle

public TreeNode<K,V> getMiddle()

getRight

public TreeNode<K,V> getRight()

getLeftMaxKey

public K getLeftMaxKey()

getMiddleMaxKey

public K getMiddleMaxKey()

getRightMaxKey

public K getRightMaxKey()

toString

public String toString()
Overrides:
toString in class Object

cursor

@Nonnull
public Cursor<JImmutableMap.Entry<K,V>> cursor()
Description copied from class: TreeNode
Returns a Cursor visiting all entries in sorted order.

Specified by:
cursor in interface Cursorable<JImmutableMap.Entry<K,V>>
Specified by:
cursor in class TreeNode<K,V>

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2014 Burton Computer Corporation. All rights reserved.