All Packages Class Hierarchy This Package Previous Next Index
Class set.Set
java.lang.Object
|
+----set.Set
- public class Set
- extends Object
- implements Element
The class Set implements set operations on linearly ordered elements.
This implementation of sets assumes elements are immutable.
Note that a set may be an element of a set or a component of an
element of a set.
The elements of a set are stored in a sorted list. An alternative
might use hash tables instead of lists, but hash tables were thought
to use too much space.
Declaring this class final seems to expose a compiler error when
using the -O switch. Code running as an applet in the appletviewer
produce
java.lang.IllegalAccessError: set.Set.t
- See Also:
- Element
-
Set()
-
-
adjoin(Element)
- Adjoin an element to a set.
-
but_first()
- The set minus its first element.
-
card()
- Set Cardinality.
-
empty()
- Is this the empty set?
-
first()
- Pick an element from the set.
-
intersect(Set)
- Set intersection.
-
less(Element)
- Is this element less than some other element?
-
member(Element)
- Is an element a member of this set?
-
proper_subset(Set)
- Is this set a proper subset of another set?
-
remove(Element)
- Remove an element from a set.
-
same(Element)
- Is this element equal to some other element?
-
set_difference(Set)
- Set difference.
-
union(Set)
- Set union.
Set
public Set()
empty
public boolean empty()
- Is this the empty set?
- Returns:
- true if this is the empty set
adjoin
public Set adjoin(Element e)
- Adjoin an element to a set.
- Parameters:
- e - the element to add
- Returns:
- the new set
remove
public Set remove(Element e)
- Remove an element from a set.
- Parameters:
- e - the element to remove
- Returns:
- the new set
member
public boolean member(Element e)
- Is an element a member of this set?
- Parameters:
- e - the element
- Returns:
- true if element is in the set
proper_subset
public boolean proper_subset(Set s)
- Is this set a proper subset of another set?
- Parameters:
- s - the other set
- Returns:
- true if this set is a proper subset of the other
union
public Set union(Set s)
- Set union.
- Parameters:
- s - the other set
- Returns:
- the union of this set and the other
intersect
public Set intersect(Set s)
- Set intersection.
- Parameters:
- s - the other set
- Returns:
- the intersection of this set and the other
set_difference
public Set set_difference(Set s)
- Set difference.
- Parameters:
- s - the other set
- Returns:
- the set difference of this set and the other
first
public Element first()
- Pick an element from the set.
- Returns:
- some element
but_first
public Set but_first()
- The set minus its first element.
- Returns:
- the set with the first element removed
card
public int card()
- Set Cardinality.
- Returns:
- the number of elments that are in the set
same
public boolean same(Element e)
- Is this element equal to some other element?
- See Also:
- same
less
public boolean less(Element e)
- Is this element less than some other element?
- See Also:
- less
All Packages Class Hierarchy This Package Previous Next Index