Package com.tangosol.util
Class StringTable
java.lang.Object
com.tangosol.util.Base
com.tangosol.util.StringTable
- All Implemented Interfaces:
Serializable
,Cloneable
Like a hash table, but built specifically for strings. Enumerates contents
in order.
- Version:
- 1.00 09/03/97
- Author:
- Cameron Purdy
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstruct a string table using all defaults.StringTable
(int nStrength) Construct a string table using the specified collator strength.StringTable
(Collator collator) Construct a string table using the specified collator. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the passed string to the table.boolean
addAll
(StringTable that) Adds all of the nodes in the specified StringTable to this StringTable if they are not already present.void
clear()
Remove all strings from the table.clone()
Make a new string table with a copy of the tree and a copy of the collator.boolean
Determine if the passed string is in the table.elements()
Create an enumerator for the values in the table.boolean
Test for equality of two string tables.Find the specified string in the table and return its value.int
getSize()
Determine the number of strings in the table.boolean
isEmpty()
Test for empty table.keys()
Enumerate the table's strings.boolean
keysEquals
(StringTable that) Test for equality of the keys in two string tables.void
Add the passed string to the table and associate the passed value with the string.void
putAll
(StringTable that) Puts all of the nodes in the specified StringTable to this StringTable including the ones that are already present.Remove the specified string from the table, returning its associated value.boolean
removeAll
(StringTable that) Removes from this StringTable all of its nodes that are contained in the specified StringTable.boolean
retainAll
(StringTable that) Retains only the nodes in this StringTable that are contained in the specified StringTable.String[]
strings()
Get the table's strings.String[]
stringsStartingWith
(String prefix) Get the table's strings that start with a specific string.toString()
Provide a string representation of the string table.Methods inherited from class com.tangosol.util.Base
azzert, 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
-
Constructor Details
-
StringTable
public StringTable()Construct a string table using all defaults. -
StringTable
Construct a string table using the specified collator.- Parameters:
collator
- an instance of java.text.Collator to use to compare strings- See Also:
-
StringTable
public StringTable(int nStrength) Construct a string table using the specified collator strength.- Parameters:
nStrength
- a valid value for java.text.Collator- See Also:
-
-
Method Details
-
add
Add the passed string to the table.- Parameters:
string
- the string to add to the table
-
put
Add the passed string to the table and associate the passed value with the string. If the string is already in the table, the passed value will replace the current value stored with the string.- Parameters:
string
- the string to add to the tablevalue
- the object to associate with the string
-
get
Find the specified string in the table and return its value.- Parameters:
string
- the string to look for in the table- Returns:
- the associated value or null if the string is not in the table
-
contains
Determine if the passed string is in the table.- Parameters:
string
- the string to look for in the table- Returns:
- true if the string is in the table, false otherwise
-
remove
Remove the specified string from the table, returning its associated value.- Parameters:
string
- the string to look for in the table- Returns:
- the associated value (which can be null) or null if the string is not in the table
-
clear
public void clear()Remove all strings from the table. -
getSize
public int getSize()Determine the number of strings in the table.- Returns:
- the number of strings in the table
-
isEmpty
public boolean isEmpty()Test for empty table.- Returns:
- true if table has no strings
-
strings
Get the table's strings.- Returns:
- an array of strings.
-
stringsStartingWith
Get the table's strings that start with a specific string.- Returns:
- an array of strings.
-
keys
Enumerate the table's strings.- Returns:
- an enumerator of the table's strings
-
elements
Create an enumerator for the values in the table.- Returns:
- an enumerator of the table's values (in the same order that the strings were returned)
-
addAll
Adds all of the nodes in the specified StringTable to this StringTable if they are not already present. This operation effectively modifies this StringTable so that its value is the union of the two StringTables. The behavior of this operation is unspecified if the specified StringTable is modified while the operation is in progress.- Returns:
- true if this StringTable changed as a result of the call.
- See Also:
-
putAll
Puts all of the nodes in the specified StringTable to this StringTable including the ones that are already present. This operation effectively modifies this StringTable so that its value is the union of the two StringTables. The behavior of this operation is unspecified if the specified StringTable is modified while the operation is in progress. -
retainAll
Retains only the nodes in this StringTable that are contained in the specified StringTable. In other words, removes from this StringTable all of its nodes that are not contained in the specified StringTable. This operation effectively modifies this StringTable so that its value is the intersection of the two StringTables.- Returns:
- true if this Collection changed as a result of the call.
- See Also:
-
removeAll
Removes from this StringTable all of its nodes that are contained in the specified StringTable. This operation effectively modifies this StringTable so that its value is the asymmetric set difference of the two StringTables.- Returns:
- true if this StringTable changed as a result of the call.
- See Also:
-
toString
Provide a string representation of the string table. -
equals
Test for equality of two string tables. -
keysEquals
Test for equality of the keys in two string tables.- Parameters:
that
- the string table to compare to- Returns:
- true if the both string tables have the same keys
-
clone
Make a new string table with a copy of the tree and a copy of the collator.
-