|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractSet
mathCollection.AbstractMathSet
This class provides a skeletal implementation of the MathSet
interface to minimize the effort required to implement this
interface.
Set
,
AbstractSet
,
HashMathSet
Constructor Summary | |
AbstractMathSet()
|
Method Summary | |
int |
hashCode()
Returns the hash code value for this mathematical set. |
boolean |
isDisjoint(java.util.Set s)
Returns true if this mathematical set has no common
elements with the specified set. |
boolean |
isSubset(java.util.Set s)
Returns true if this mathematical set is a subset of the
specified set. |
boolean |
isSuperset(java.util.Set s)
Returns true if this mathematical set is a superset of the
specified set. |
java.lang.String |
toString()
Returns a string representation of this mathematical set. |
Methods inherited from class java.util.AbstractSet |
equals, removeAll |
Methods inherited from class java.util.AbstractCollection |
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, retainAll, size, toArray, toArray |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface mathCollection.MathSet |
difference, fixedSizeSubsets, intersection, powerSet, symmetricDifference, union |
Methods inherited from interface java.util.Set |
add, addAll, clear, contains, containsAll, equals, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Constructor Detail |
public AbstractMathSet()
Method Detail |
public int hashCode()
s1.equals(s2)
implies that
s1.hashCode()==s2.hashCode()
for any two mathematical sets
s1
and s2
, as required by the general contract
of Object.hashCode()
.
hashCode
in interface java.util.Set
public java.lang.String toString()
"{}"
). Adjacent elements are separated by the characters
", "
(comma and space). Elements are converted to strings as
by Object.toString()
.
public boolean isSuperset(java.util.Set s)
true
if this mathematical set is a superset of the
specified set. That is, if all elements of the specified set are also
present in this mathematical set.
This implementation first compares the sizes of this mathematical set and
the specified set by invoking the size
method on each. If
this mathematical set is bigger than the specified set then each element
of the specified set is checked for presence in this mathematical set.
Otherwise, false
is returned.
isSuperset
in interface MathSet
s
- set to be checked for being a subset.
true
if this mathematical set is a superset of the
specifed set, false
otherwise.isSubset(Set)
public boolean isSubset(java.util.Set s)
true
if this mathematical set is a subset of the
specified set. That is, if all elements of this mathematical set are also
present in the specified set.
This implementation first compares the sizes of this mathematical set and
the specified set by invoking the size
method on each. If
this mathematical set is smaller than the specified set then the
intersection of this mathematical set with the specified set is
calculated. If the intersection has as many elements as this mathematical
set then true
is returned, false
otherwise.
isSubset
in interface MathSet
s
- set to be checked for being a superset.
true
if this mathematical set is a subset of the
specifed set, false
otherwise.isSuperset(Set)
public boolean isDisjoint(java.util.Set s)
true
if this mathematical set has no common
elements with the specified set.
This implementation determines which is the smaller of this set
and the specified set by invoking the size()
method on each. If this set has fewer elements, then the
implementation iterates over this set, checking each element
returned by the iterator in turn to see if it is contained in
the specified set. If it is so contained, false
is returned. If the specified set has fewer elements,
then the implementation iterates over the specified set,
returning false
if it finds a common element.
isDisjoint
in interface MathSet
s
- set to be checked for common elements.
true
if this mathematical set has no common
elements with the specifed set, false
otherwise.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |