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.


Variable Index

 o table_

Constructor Index

 o Set()
Creates an empty set with default capacity.
 o Set(int)
Creates an empty set with a given initial capacity.

Method Index

 o apply(UnaryFunction)
Applies the unary function to every element of the collection in turn.
 o clear()
Removes all elements from the collection.
 o clone()
Returns a clone of this Set.
 o contains(Object)
Returns true if the Set contains an element equal to the given item, false otherwise.
 o difference(Set, Set)
Returns a new Set containing the difference (A - B) of the two Sets specified.
 o differenceWith(Set)
Modifies self to contain the difference of self with the given set (self = self - set)
 o elements()
Returns an Enumeration object, which can be used to visit each element of the collection in turn.
 o find(Object)
Returns the element equal to the given item, or null if no such element is found.
 o insert(Object)
Adds a new item to the Set.
 o insertMany(Enumeration)
Adds the items enumerated by the given Enumeration.
 o intersection(Set, Set)
Returns a new set containing the intersection of the two Sets specified.
 o intersectionWith(Set)
Modifies self to contain the intersection of self and the given set.
 o isEmpty()
Returns true if the collection is empty
 o occurrencesOf(Object)
Returns the number of elements in the collection equal to to the given item.
 o reduce(BinaryFunction, Object)
Reduces the collection to a single value.
 o remove(Object)
Removes from the set the element equal to the given item.
 o removeAll(Object)
Removes from the set all elements that are equal to the given item.
 o removeMany(Enumeration)
Removes all of the elements enumerated by the Enumeration from the set.
 o size()
Returns the number of entries in the collection
 o 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).

 o 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).

 o toString()
Converts this set into a string of the form
   "[e1, e2, e3, ...]"
 
An empty list returns the string "[]".
 o union(Set, Set)
Returns a new set containing the union of the two Sets specified.
 o unionWith(Set)
Modifies self to contain the union of self and the given set.

Variables

 o table_
 protected Hashtable table_

Constructors

 o Set
 public Set()
Creates an empty set with default capacity.

 o Set
 public Set(int n)
Creates an empty set with a given initial capacity.

Parameters:
n - The initial capacity of the underlying Hashtable

Methods

 o 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.

 o clear
 public synchronized void clear()
Removes all elements from the collection.

 o clone
 public synchronized Object clone()
Returns a clone of this Set. Note that the elements themselves are not cloned.

Overrides:
clone in class Object
 o contains
 public boolean contains(Object item)
Returns true if the Set contains an element equal to the given item, false otherwise.

 o find
 public Object find(Object item)
Returns the element equal to the given item, or null if no such element is found.

 o 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.
 o insertMany
 public synchronized int insertMany(Enumeration e)
Adds the items enumerated by the given Enumeration.

Returns:
The number of new elements added.
 o isEmpty
 public final boolean isEmpty()
Returns true if the collection is empty

 o size
 public final int size()
Returns the number of entries in the collection

 o elements
 public Enumeration elements()
Returns an Enumeration object, which can be used to visit each element of the collection in turn.

 o 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.

 o 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.
 o 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.
 o 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.
 o 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
 o 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
 o intersection
 public static Set intersection(Set s1,
                                Set s2)
Returns a new set containing the intersection of the two Sets specified.

 o intersectionWith
 public Set intersectionWith(Set set)
Modifies self to contain the intersection of self and the given set.

Returns:
self
 o difference
 public static Set difference(Set s1,
                              Set s2)
Returns a new Set containing the difference (A - B) of the two Sets specified.

 o differenceWith
 public Set differenceWith(Set set)
Modifies self to contain the difference of self with the given set (self = self - set)

Returns:
self
 o 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).

 o 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
 o union
 public static Set union(Set s1,
                         Set s2)
Returns a new set containing the union of the two Sets specified.

 o 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