All Packages Class Hierarchy This Package Previous Next Index
Class com.roguewave.tools.v2-0.Set
java.lang.Object
|
+----com.roguewave.tools.v2-0.Set
- public class Set
- extends Object
- implements Cloneable, Collection, Serializable
Class Set uses an underlying Hashtable to implement an
unordered collection of elements where duplicate entries
are not allowed. Unlike Hashtable in the java.util package,
elements are taken singly,
that is, Sets traffic in single objects, not in keys and values.
Equality of objects is determined by using the
hashCode() and equals(Object)
methods inherited or overridden from class Object.
-
table_
-
-
Set()
- Creates an empty set with default capacity.
-
Set(int)
- Creates an empty set with a given initial capacity.
-
apply(UnaryFunction)
- Applies the unary function to every element of the collection
in turn.
-
clear()
-
Removes all elements from the collection.
-
clone()
- Returns a clone of this Set.
-
contains(Object)
- Returns true if the Set contains an element equal to the
given item, false otherwise.
-
difference(Set, Set)
- Returns a new Set containing the difference (A - B)
of the two Sets specified.
-
differenceWith(Set)
- Modifies self to contain the difference of self with the given set
(self = self - set)
-
elements()
- Returns an Enumeration object, which can be used to visit
each element of the collection in turn.
-
find(Object)
-
Returns the element equal to the given item, or null if no such element
is found.
-
insert(Object)
-
Adds a new item to the Set.
-
insertMany(Enumeration)
- Adds the items enumerated by the given Enumeration.
-
intersection(Set, Set)
- Returns a new set containing the intersection of the two Sets
specified.
-
intersectionWith(Set)
- Modifies self to contain the intersection of self
and the given set.
-
isEmpty()
- Returns true if the collection is empty
-
occurrencesOf(Object)
- Returns the number of elements in the collection equal to
to the given item.
-
reduce(BinaryFunction, Object)
- Reduces the collection to a single value.
-
remove(Object)
- Removes from the set the element equal to the given item.
-
removeAll(Object)
- Removes from the set all elements that are equal to the given item.
-
removeMany(Enumeration)
- Removes all of the elements enumerated by the
Enumeration from the set.
-
size()
- Returns the number of entries in the collection
-
symmetricDifference(Set, Set)
- Returns a new set containing the symmetric difference between the two
Sets specified.
The symmetric difference between Set A and Set B is the difference (A - B)
unioned with the difference (B - A).
-
symmetricDifferenceWith(Set)
- Modifies self to contain the symmetric difference between self
and the given set.
The symmetric difference between Set A and Set B is the difference (A - B)
unioned with the difference (B - A).
-
toString()
- Converts this set into a string of the form
"[e1, e2, e3, ...]"
An empty list returns the string "[]".
-
union(Set, Set)
- Returns a new set containing the union of the two Sets specified.
-
unionWith(Set)
- Modifies self to contain the union of self and the given set.
table_
protected Hashtable table_
Set
public Set()
- Creates an empty set with default capacity.
Set
public Set(int n)
- Creates an empty set with a given initial capacity.
- Parameters:
- n - The initial capacity of the underlying Hashtable
apply
public synchronized void apply(UnaryFunction f)
- Applies the unary function to every element of the collection
in turn. Note that the return value of the unary function is
ignored.
clear
public synchronized void clear()
- Removes all elements from the collection.
clone
public synchronized Object clone()
- Returns a clone of this Set. Note that the elements
themselves are not cloned.
- Overrides:
- clone in class Object
contains
public boolean contains(Object item)
- Returns true if the Set contains an element equal to the
given item, false otherwise.
find
public Object find(Object item)
- Returns the element equal to the given item, or null if no such element
is found.
insert
public synchronized Object insert(Object item)
- Adds a new item to the Set.
The insertion fails if the Set already contains an element
equal to item.
- Returns:
- The new element if the insertion is
successful, or the existing element if it is not.
insertMany
public synchronized int insertMany(Enumeration e)
- Adds the items enumerated by the given Enumeration.
- Returns:
- The number of new elements added.
isEmpty
public final boolean isEmpty()
- Returns true if the collection is empty
size
public final int size()
- Returns the number of entries in the collection
elements
public Enumeration elements()
- Returns an Enumeration object, which can be used to visit
each element of the collection in turn.
occurrencesOf
public int occurrencesOf(Object item)
- Returns the number of elements in the collection equal to
to the given item. Because this class does not admit duplicate entries,
the return value will always be either 1 or 0.
reduce
public synchronized Object reduce(BinaryFunction f,
Object identity)
- Reduces the collection to a single value. A result
is initialized with identity. Then, for each element
in the collection, a new result is computed by calling
the binary function on the current result and the next element.
- Returns:
- The result as described above, or identity
if the collection is empty.
remove
public synchronized Object remove(Object item)
- Removes from the set the element equal to the given item.
The method does nothing if no such element is found.
- Returns:
- The removed element, or null
if no such element is found.
removeMany
public synchronized int removeMany(Enumeration e)
- Removes all of the elements enumerated by the
Enumeration from the set.
- Returns:
- The number of elements removed.
removeAll
public int removeAll(Object item)
- Removes from the set all elements that are equal to the given item.
Note that since collection does not admit
duplicate entries, the maximum number of elements removed
will be 1.
- Returns:
- The number of elements removed
toString
public synchronized String toString()
- Converts this set into a string of the form
"[e1, e2, e3, ...]"
An empty list returns the string "[]".
- Overrides:
- toString in class Object
intersection
public static Set intersection(Set s1,
Set s2)
- Returns a new set containing the intersection of the two Sets
specified.
intersectionWith
public Set intersectionWith(Set set)
- Modifies self to contain the intersection of self
and the given set.
- Returns:
- self
difference
public static Set difference(Set s1,
Set s2)
- Returns a new Set containing the difference (A - B)
of the two Sets specified.
differenceWith
public Set differenceWith(Set set)
- Modifies self to contain the difference of self with the given set
(self = self - set)
- Returns:
- self
symmetricDifference
public static Set symmetricDifference(Set s1,
Set s2)
- Returns a new set containing the symmetric difference between the two
Sets specified.
The symmetric difference between Set A and Set B is the difference (A - B)
unioned with the difference (B - A).
symmetricDifferenceWith
public Set symmetricDifferenceWith(Set set)
- Modifies self to contain the symmetric difference between self
and the given set.
The symmetric difference between Set A and Set B is the difference (A - B)
unioned with the difference (B - A).
- Returns:
- self
union
public static Set union(Set s1,
Set s2)
- Returns a new set containing the union of the two Sets specified.
unionWith
public Set unionWith(Set set)
- Modifies self to contain the union of self and the given set.
- Returns:
- self
All Packages Class Hierarchy This Package Previous Next Index