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.


Constructor Index

 o SetList()
Construct a new set list.

Method Index

 o add(Object)
Add an element to set, if not already present.
 o clear()
Remove all the elements from the set.
 o clone()
Returns a shallow clone of this set.
 o contains(Object)
Returns true if value is an element of the set.
 o difference(Set)
Compute the difference between two sets.
 o elements()
Construct an iterator to traverse the elements of the set.
 o intersection(Set)
Compute the intersection of this set and other.
 o isEmpty()
Determine if the set is empty.
 o remove(Object)
Remove an element from the set.
 o size()
Determine the number of elements in the set.
 o subset(Set)
Determine if this set is a subset of other.
 o toString()
Construct a string representation of the set.
 o union(Set)
Compute the union of this set with other.

Constructors

 o SetList
public SetList()
Construct a new set list.

Postcondition:
constructs a new, empty set

Methods

 o clear
public void clear()
Remove all the elements from the set.

Postcondition:
elements of set are removed

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