All Packages Class Hierarchy This Package Previous Next Index
Class structure.SetList
java.lang.Object
|
+----structure.SetList
- public class SetList
- extends Object
- implements Set
An implementation of a set using lists.
SetList()
- Construct a new set list.
add(Object)
- Add an element to set, if not already present.
clear()
- Remove all the elements from the set.
clone()
- Returns a shallow clone of this set.
contains(Object)
- Returns true if value is an element of the set.
difference(Set)
- Compute the difference between two sets.
elements()
- Construct an iterator to traverse the elements of the set.
intersection(Set)
- Compute the intersection of this set and other.
isEmpty()
- Determine if the set is empty.
remove(Object)
- Remove an element from the set.
size()
- Determine the number of elements in the set.
subset(Set)
- Determine if this set is a subset of other.
toString()
- Construct a string representation of the set.
union(Set)
- Compute the union of this set with other.
SetList
public SetList()
- Construct a new set list.
- Postcondition:
- constructs a new, empty set
clear
public void clear()
- Remove all the elements from the set.
- Postcondition:
- elements of set are removed
isEmpty
public boolean isEmpty()
- Determine if the set is empty.
- Postcondition:
- returns true iff set is empty
- Returns:
- True iff there are no elements in set.
add
public void add(Object e)
- Add an element to set, if not already present.
- Precondition:
- e is non-null object
- Postcondition:
- adds element e to interface
- Parameters:
- e - The new value to be added to set.
remove
public Object remove(Object e)
- Remove an element from the set.
- Precondition:
- e is non-null object
- Postcondition:
- e is removed from set, value returned
- Parameters:
- e - The element of the set to be removed.
- Returns:
- The value actually removed.
contains
public boolean contains(Object e)
- Returns true if value is an element of the set.
- Precondition:
- e is non-null
- Postcondition:
- returns true iff e is in set
- Parameters:
- e - The element sought in set.
- Returns:
- True iff the element is in the set.
subset
public boolean subset(Set other)
- Determine if this set is a subset of other.
- Precondition:
- other is non-null reference to set
- Postcondition:
- returns true iff this set is subset of other
- Parameters:
- other - The potential superset.
clone
public Object clone()
- Returns a shallow clone of this set.
- Postcondition:
- returns a copy of set
- Returns:
- A new set with same values.
- Overrides:
- clone in class Object
union
public Object union(Set other)
- Compute the union of this set with other.
This set not modified.
- Precondition:
- other is non-null reference to set
- Postcondition:
- returns new set containing union of this and other
- Parameters:
- other - The set to be unioned with this.
- Returns:
- Union of this and other.
intersection
public Object intersection(Set other)
- Compute the intersection of this set and other.
Members of result are in both this and other.
- Precondition:
- other is non-null reference to set
- Postcondition:
- returns new set containing intersection of this and other
- Parameters:
- other - The other set to be intersected with this.
- Returns:
- Intersection of this and other.
difference
public Object difference(Set other)
- Compute the difference between two sets.
Values of the result are members of this, but not other.
- Precondition:
- other is non-null reference to set
- Postcondition:
- returns new set containing difference of this and other
- Parameters:
- other - The set whose values are to be eliminated from this.
- Returns:
- Difference between this and other.
elements
public Iterator elements()
- Construct an iterator to traverse the elements of the set.
Elements will not appear in any particular order.
- Postcondition:
- returns iterator to traverse the elements of set
- Returns:
- An iterator for inspecting members of the set.
size
public int size()
- Determine the number of elements in the set.
- Postcondition:
- returns number of elements in set
- Returns:
- The number of elements in the set.
toString
public String toString()
- Construct a string representation of the set.
- Postcondition:
- returns a string representation of set
- Returns:
- A string representing the set.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index