|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrebuild.collections.CollectionUtilities
public final class CollectionUtilities
Various utilities and functions related to collections.
Method Summary | |
---|---|
static boolean |
equals(java.util.Hashtable main,
java.util.Hashtable comp)
Perform a shallow comparison of two Hashtables to determine if they are equal. |
static boolean |
equals(java.util.Vector main,
java.util.Vector comp)
Perform a shallow comparison of two Vectors to determine if they are equal. |
static void |
putAll(java.util.Hashtable dest,
java.util.Hashtable source)
Copies all of the mappings from the specified table to another table. |
static void |
putAll(java.util.Vector dest,
java.util.Vector source)
Copies all of the elements from the specified Vector to another Vector. |
static java.util.Hashtable |
readonlyTable(java.util.Hashtable table)
Returns a wrapper on the specified table which has readonly access to the table. |
static java.util.Vector |
readonlyVector(java.util.Vector vector)
Returns a wrapper on the specified Vector which has readonly access to the Vector. |
static java.util.Hashtable |
synchronizedTable(java.util.Hashtable table)
Returns a synchronized (thread-safe) table backed by the specified table. |
static java.util.Vector |
synchronizedVector(java.util.Vector vector)
Returns a synchronized (thread-safe) Vector backed by the specified Vector. |
static java.lang.Object[] |
toArray(java.util.Vector vect)
Convert a Vector to an array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.Object[] toArray(java.util.Vector vect)
Vector
to an array.
vect
- The Vector
to convert to an array.
null
then null
is returned. Else an array is returned of the
items in vect.public static boolean equals(java.util.Vector main, java.util.Vector comp)
main
- The first Vector for comparison.comp
- The second Vector to compare to the main Vector.
true
if the vectors are the same, false
if otherwise.public static boolean equals(java.util.Hashtable main, java.util.Hashtable comp)
main
- The first Hashtable for comparison.comp
- The second Hashtable to compare to the main Hashtable.
true
if the tables are the same, false
if otherwise.public static void putAll(java.util.Hashtable dest, java.util.Hashtable source)
dest
- the table to store the elements insource
- mappings to be stored in the dest table
java.lang.NullPointerException
- if the specified tables are nullpublic static void putAll(java.util.Vector dest, java.util.Vector source)
dest
- the Vector to store the elements insource
- elements to be stored in the dest Vector
java.lang.NullPointerException
- if the specified Vectors are nullpublic static java.util.Vector synchronizedVector(java.util.Vector vector)
It is imperative that the user manually synchronize on the returned Vector when enumerating over it:
Vector vector = CollectionUtilities.synchronizedVector(new Vector());
...
synchronized (vector) {
Enumeration e = vector.elements(); // Must be in synchronized block
while (e.hasMoreElements())
foo(e.nextElement());
}
vector
- the Vector to wrap in a synchronized Vector.
public static java.util.Hashtable synchronizedTable(java.util.Hashtable table)
It is imperative that the user manually synchronize on the returned table when enumerating over it:
Hashtable table = CollectionUtilities.synchronizedTable(new Hashtable());
...
synchronized (table) {
Enumeration e = table.elements(); // Must be in synchronized block
while (e.hasMoreElements())
foo(e.nextElement());
...
Enumeration k = table.keys(); // Must be in synchronized block
while (k.hasMoreElements())
foo(k.nextElement());
}
table
- The table to make synchronized.
public static java.util.Vector readonlyVector(java.util.Vector vector)
vector
- the Vector to wrap in a readonly Vector.
public static java.util.Hashtable readonlyTable(java.util.Hashtable table)
table
- the table to wrap in a readonly table.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |