|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Set
An abstract data type meant to serve as a representation of a mathematical set, containing non-negative integers below a certain value and with methods to manipulate the set.
Field Summary | |
static int |
MAXIMUM
The maximum valid integer element that a Set object can
contain. |
static int |
MINIMUM
The minimum valid integer element that a Set object can
contain. |
Constructor Summary | |
Set()
Constructs an instance of the Set class that is an empty
set. |
Method Summary | |
void |
addElement(int element)
Adds a new element to the Set . |
java.lang.Object |
clone()
Generates a copy of this Set object. |
static Set |
complement(Set s)
Generates and returns the complement of the given Set
object. |
static Set |
difference(Set s1,
Set s2)
Generates and returns the difference of two given Set
objects. |
boolean |
equals(java.lang.Object obj)
Compares this Set to another object for equality. |
int |
getSize()
Accessor method for getting the number of elements in the Set object. |
static Set |
intersection(Set s1,
Set s2)
Generates and returns the intersection of two given Set
objects. |
boolean |
isMember(int element)
Determines if the given element is a member of this Set . |
static Set[] |
powerset(Set s)
Generates and returns the powerset of the given Set
object. |
int |
setOrderComparision(Set otherSet)
A method that compares this Set object to another to
determine in which order the sets would appear lexicographically. |
static Set[] |
sortPowerset(Set[] ps)
Generates an array of Set objects that contains all the
elements from another array of Set objects after they have
been placed into a more presentable and readable order. |
java.lang.String |
toString()
Returns the String representation of this Set
object. |
static Set |
union(Set s1,
Set s2)
Generates and returns the union of two given Set objects. |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int MAXIMUM
Set
object can
contain.public static final int MINIMUM
Set
object can
contain.Constructor Detail |
public Set()
Set
class that is an empty
set.
Set
has been initialized as an empty set.OutOfMemoryError
- Indicates insufficient memory for creating this Set
object.Method Detail |
public void addElement(int element) throws IllegalElementException
Set
.element
- a new element to be added to this Set
Set
has been instantiated and element is within the
valid range.
Set
object, nothing will
change. Otherwise, the element is added to the set.IllegalElementException
- Indicates that element
is outside of the permitted range.public java.lang.Object clone() throws java.lang.RuntimeException
Set
object.clone
in class java.lang.Object
Set
. Subsequent changes
to the copy will not affect the original, nor vice versa. Note that the
return value must be typecast to a Set
before it can be
used.OutOfMemoryError
- Indicates insufficient memory for cloning this Set
object.java.lang.RuntimeException
- Indicates that the class doesn't implement the Cloneable
interface. (though this should never occur)
Object
to a
Set
before use.public static Set complement(Set s) throws IllegalElementException
Set
object.s
- the Set
for which a complement is to be generated for
Set
object referenced by s
has been
instantiated.Set
containing the complement of the given
Set
parameter.IllegalElementException
- Indicates that the set containes an element oustide of the valid range.
s
is null.public static Set difference(Set s1, Set s2) throws IllegalElementException
Set
objects.s1
- the first Set
s2
- the second Set
Set
objects referenced by s1
and
s2
have both been instantiated.Set
containing the difference of the given
Set
parameters.IllegalElementException
- Indicates that one of the sets containes an element oustide of the valid
range.
s1
or s2
is
null.public boolean equals(java.lang.Object obj)
Set
to another object for equality.equals
in class java.lang.Object
obj
- an object to which this Set
is being compared withtrue
indicates that obj refers to a
Set
object with the same elements as this Set
.
Otherwise, the return value is false
.public int getSize()
Set
object.Set
object.public static Set intersection(Set s1, Set s2) throws IllegalElementException
Set
objects.s1
- the first Set
s2
- the second Set
Set
objects referenced by s1
and
s2
have both been instantiated.Set
containing the intersection of the given
Set
parameters.IllegalElementException
- Indicates that one of the sets containes an element oustide of the valid
range.
s1
or s2
is
null.public boolean isMember(int element) throws IllegalElementException
Set
.element
- the element to be searched for in the Set
Set
has been instantiated and element is within the
valid range.true
indicates that the given element is a
member of this set. Otherwise, the return value is false
IllegalElementException
- Indicates that element
is outside of the permitted range.public static Set[] powerset(Set s) throws IllegalElementException
Set
object.s
- the Set
for which a powerset is to be generated for
Set
object referenced by s
has been
instantiated.Set
objects containing sets which are elements
of the powerset of the given Set
parameter.IllegalElementException
- Indicates that a set containes an element oustide of the valid range.
s
is null.public int setOrderComparision(Set otherSet)
Set
object to another to
determine in which order the sets would appear lexicographically.otherSet
- the Set
object to which this one is being compared withSet
object comes
before the one it is compared to, 1 means that it comes after it, and 0
means that both sets are the same.NullPointerException
- Indicates that otherSet
is a null reference.public static Set[] sortPowerset(Set[] ps)
Set
objects that contains all the
elements from another array of Set
objects after they have
been placed into a more presentable and readable order.ps
- the array of Set
objects to be sorted
ps
is not null.Set
objects that is a sorted
version of the parameter ps
.NullPointerException
- Indicates that ps
is a null reference.public java.lang.String toString()
String
representation of this Set
object.toString
in class java.lang.Object
String
representation of this
Set
object.public static Set union(Set s1, Set s2) throws IllegalElementException
Set
objects.s1
- the first Set
s2
- the second Set
Set
objects referenced by s1
and
s2
have both been instantiated.Set
containing the union of the given Set
parameters.IllegalElementException
- Indicates that one of the sets containes an element oustide of the valid
range.
s1
or s2
is
null.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |