Package com.tangosol.util
Class Tree
- java.lang.Object
- 
- com.tangosol.util.Base
- 
- com.tangosol.util.Tree
 
 
- 
- All Implemented Interfaces:
- Serializable,- Cloneable
 
 public class Tree extends Base implements Cloneable, Serializable A thread-safe balanced binary search tree.As of Coherence 3.3 this class is a wrapper around TreeMap.Note: Where practical, use java.util.TreeMap; including external syncronization as necessary.- Author:
- cp 1997.09.05; mf 2007.10.16
- See Also:
- Serialized Form
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class com.tangosol.util.BaseBase.LoggingWriter
 
- 
 - 
Constructor SummaryConstructors Constructor Description Tree()Default constructor.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Comparable key)Add the passed key to the tree.booleanaddAll(Tree that)Adds all of the nodes in the specified Tree to this Tree if they are not already present.voidclear()Remove all nodes from the tree.Objectclone()Make a shallow copy of the tree and its nodes.booleancontains(Comparable key)Determine if the passed key is in the tree.Enumerationelements()Create an enumerator for the tree's values.booleanequals(Object obj)Test for tree equality.Objectget(Comparable key)Find the specified key and return its value.intgetSize()Determine the size of the tree.protected EnumerationgetUnsynchronizedKeyEnumerator()Get an enumerator of the nodes in the tree.protected EnumerationgetUnsynchronizedKeyEnumerator(Comparable key)Get an enumerator of the nodes in the tree.booleanisEmpty()Test for empty tree.Enumerationkeys()Create an in-order enumerator for the tree's keys.voidprint()In-order printing of the contents of the tree.voidput(Comparable key, Object value)Add the passed key to the tree and associate the passed value with the key.voidputAll(Tree that)Puts all of the nodes in the specified Tree to this Tree (including the ones that are already present).Objectremove(Comparable key)Remove the specified key from the tree, returning its associated value.booleanremoveAll(Tree that)Removes from this Tree all of its nodes that are contained in the specified Tree.booleanretainAll(Tree that)Retains only the nodes in this Tree that are contained in the specified Tree.StringtoString()Provide a string representation of the tree.- 
Methods inherited from class com.tangosol.util.Baseazzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
 
- 
 
- 
- 
- 
Field Detail- 
m_treeprotected TreeMap m_tree The delgate tree.
 
- 
 - 
Method Detail- 
addpublic void add(Comparable key) Add the passed key to the tree.- Parameters:
- key- the key to add to the tree
 
 - 
putpublic void put(Comparable key, Object value) Add the passed key to the tree and associate the passed value with the key. If the key is already in the tree, the passed value will replace the current value stored with the key.- Parameters:
- key- the key to add to the tree
- value- the object to associate with the key
 
 - 
getpublic Object get(Comparable key) Find the specified key and return its value.- Parameters:
- key- the key to look for in the tree
- Returns:
- the associated value or null if the key is not in the tree
 
 - 
containspublic boolean contains(Comparable key) Determine if the passed key is in the tree.- Parameters:
- key- the key to look for in the tree
- Returns:
- true if the key is in the tree, false otherwise
 
 - 
removepublic Object remove(Comparable key) Remove the specified key from the tree, returning its associated value.- Parameters:
- key- the key to look for in the tree
- Returns:
- the associated value (which can be null) or null if the key is not in the tree
 
 - 
clearpublic void clear() Remove all nodes from the tree.
 - 
getSizepublic int getSize() Determine the size of the tree.- Returns:
- the number of nodes in the tree
 
 - 
isEmptypublic boolean isEmpty() Test for empty tree.- Returns:
- true if tree has no nodes
 
 - 
keyspublic Enumeration keys() Create an in-order enumerator for the tree's keys.- Returns:
- an enumerator of the tree's keys
 
 - 
elementspublic Enumeration elements() Create an enumerator for the tree's values.- Returns:
- an enumerator of the tree's values (in the same order that the keys were returned)
 
 - 
addAllpublic boolean addAll(Tree that) Adds all of the nodes in the specified Tree to this Tree if they are not already present. This operation effectively modifies this Tree so that its value is the union of the two Trees. The behavior of this operation is unspecified if the specified Tree is modified while the operation is in progress.- Returns:
- true if this Tree changed as a result of the call.
- See Also:
- Collection.addAll(Collection)
 
 - 
putAllpublic void putAll(Tree that) Puts all of the nodes in the specified Tree to this Tree (including the ones that are already present). This operation effectively modifies this Tree so that its value is the union of the two Trees. The behavior of this operation is unspecified if the specified Tree is modified while the operation is in progress.
 - 
retainAllpublic boolean retainAll(Tree that) Retains only the nodes in this Tree that are contained in the specified Tree. In other words, removes from this Tree all of its nodes that are not contained in the specified Tree. This operation effectively modifies this Tree so that its value is the intersection of the two Trees.- Returns:
- true if this Collection changed as a result of the call.
- See Also:
- Collection.retainAll(Collection)
 
 - 
removeAllpublic boolean removeAll(Tree that) Removes from this Tree all of its nodes that are contained in the specified Tree. This operation effectively modifies this Tree so that its value is the asymmetric set difference of the two Trees.- Returns:
- true if this Tree changed as a result of the call.
- See Also:
- Collection.removeAll(Collection)
 
 - 
toStringpublic String toString() Provide a string representation of the tree.
 - 
clonepublic Object clone() Make a shallow copy of the tree and its nodes. Note that cloning does make new copies of each node.
 - 
printpublic void print() In-order printing of the contents of the tree.
 - 
getUnsynchronizedKeyEnumeratorprotected Enumeration getUnsynchronizedKeyEnumerator() Get an enumerator of the nodes in the tree. This enumerator is not in any way thread-safe, so the tree should be synchronized for as long as this enumerator is in use. Note: Purposefully package private; used by StringTable
 - 
getUnsynchronizedKeyEnumeratorprotected Enumeration getUnsynchronizedKeyEnumerator(Comparable key) Get an enumerator of the nodes in the tree. This enumerator is not in any way thread-safe, so the tree should be synchronized for as long as this enumerator is in use. Note: Purposefully package private; used by StringTable
 
- 
 
-