|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jmlspecs.models.JMLEqualsSet
Sets of objects. This type uses ".equals" to compare elements, and does not clone elements that are passed into and returned from the set's methods.
For the purposes of informal specification in the methods below, we assume there is a model field
public model mathematical_set theSet;that you can think of as a mathematical set of objects.
JMLCollection,
JMLType,
JMLObjectSet,
JMLValueSet,
JMLEqualsSetEnumerator,
JMLObjectBag,
JMLEqualsBag,
JMLValueBag| Field Summary | |
static JMLEqualsSet |
EMPTY
The empty JMLEqualsSet. |
protected int |
size
The number of elements in this set. |
protected JMLListEqualsNode |
the_list
An equational specification of the properties of sets. |
| Constructor Summary | |
|
JMLEqualsSet()
Initialize this to be an empty set. |
|
JMLEqualsSet(Object e)
Initialize this to be a singleton set containing the given element. |
protected |
JMLEqualsSet(JMLListEqualsNode ls)
Initialize this set with the given list. |
protected |
JMLEqualsSet(JMLListEqualsNode ls,
int sz)
Initialize this set with the given instance variables. |
| Method Summary | |
Object |
choose()
Return an arbitrary element of this. |
Object |
clone()
Return a clone of this object. |
boolean |
containsAll(Collection c)
Tell whether, for each element in the given collection, there is a ".equals" element in this set. |
static JMLEqualsSet |
convertFrom(Object[] a)
Return the set containing all the elements in the given array. |
static JMLEqualsSet |
convertFrom(Collection c)
Return the set containing all the object in the given collection. |
static JMLEqualsSet |
convertFrom(JMLCollection c)
Return the set containing all the object in the given JMLCollection. |
JMLEqualsSet |
difference(JMLEqualsSet s2)
Returns a new set that contains all the elements that are in this but not in the given argument. |
JMLEqualsSetEnumerator |
elements()
Returns an Enumeration over this set. |
boolean |
equals(Object s2)
Test whether this object's value is equal to the given argument. |
protected JMLEqualsSet |
fast_insert(Object elem)
Returns a new set that contains all the elements of this and also the given argument, assuming the argument is not in the set. |
boolean |
has(Object elem)
Is the argument ".equals" to one of the objects in theSet. |
int |
hashCode()
Return a hash code for this object. |
JMLEqualsSet |
insert(Object elem)
Returns a new set that contains all the elements of this and also the given argument. |
int |
int_size()
Tells the number of elements in the set. |
JMLEqualsSet |
intersection(JMLEqualsSet s2)
Returns a new set that contains all the elements that are in both this and the given argument. |
boolean |
isEmpty()
Is the set empty. |
boolean |
isProperSubset(JMLEqualsSet s2)
Tells whether this set is a subset of but not equal to the argument. |
boolean |
isProperSuperset(JMLEqualsSet s2)
Tells whether this set is a superset of but not equal to the argument. |
boolean |
isSubset(JMLEqualsSet s2)
Tells whether this set is a subset of or equal to the argument. |
boolean |
isSuperset(JMLEqualsSet s2)
Tells whether this set is a superset of or equal to the argument. |
JMLIterator |
iterator()
Returns an Iterator over this set. |
JMLEqualsSet |
powerSet()
Returns a new set that is the set of all subsets of this. |
JMLEqualsSet |
remove(Object elem)
Returns a new set that contains all the elements of this except for the given argument. |
static JMLEqualsSet |
singleton(Object e)
Return the singleton set containing the given element. |
Object[] |
toArray()
Return a new array containing all the elements of this. |
JMLEqualsBag |
toBag()
Return a new JMLEqualsBag containing all the elements of this. |
JMLEqualsSequence |
toSequence()
Return a new JMLEqualsSequence containing all the elements of this. |
String |
toString()
Return a string representation of this object. |
JMLEqualsSet |
union(JMLEqualsSet s2)
Returns a new set that contains all the elements that are in either this or the given argument. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected final JMLListEqualsNode the_list
protected final int size
public static final JMLEqualsSet EMPTY
JMLEqualsSet()| Constructor Detail |
public JMLEqualsSet()
EMPTYpublic JMLEqualsSet(Object e)
singleton(java.lang.Object)
protected JMLEqualsSet(JMLListEqualsNode ls,
int sz)
protected JMLEqualsSet(JMLListEqualsNode ls)
| Method Detail |
public static JMLEqualsSet singleton(Object e)
JMLEqualsSet(Object)public static JMLEqualsSet convertFrom(Object[] a)
public static JMLEqualsSet convertFrom(Collection c)
throws ClassCastException
ClassCastException - if some element in c is not an instance of
Object.containsAll(java.util.Collection)
public static JMLEqualsSet convertFrom(JMLCollection c)
throws ClassCastException
ClassCastException - if some element in c is not an instance of
Object.public boolean has(Object elem)
has in interface JMLCollectionpublic boolean containsAll(Collection c)
c - the collection whose elements are sought.isSuperset(JMLEqualsSet),
convertFrom(java.util.Collection)public boolean equals(Object s2)
JMLType
equals in interface JMLTypeequals in class Objectpublic int hashCode()
hashCode in interface JMLTypehashCode in class Objectpublic boolean isEmpty()
int_size(),
has(Object)public int int_size()
int_size in interface JMLCollectionpublic boolean isSubset(JMLEqualsSet s2)
isProperSubset(JMLEqualsSet),
isSuperset(JMLEqualsSet)public boolean isProperSubset(JMLEqualsSet s2)
isSubset(JMLEqualsSet),
isProperSuperset(JMLEqualsSet)public boolean isSuperset(JMLEqualsSet s2)
isProperSuperset(JMLEqualsSet),
isSubset(JMLEqualsSet),
containsAll(java.util.Collection)public boolean isProperSuperset(JMLEqualsSet s2)
isSuperset(JMLEqualsSet),
isProperSubset(JMLEqualsSet)
public Object choose()
throws JMLNoSuchElementException
JMLNoSuchElementException - if this is empty.isEmpty(),
elements()public Object clone()
clone in interface JMLTypeclone in class Object
public JMLEqualsSet insert(Object elem)
throws IllegalStateException
IllegalStateExceptionhas(Object),
remove(Object)protected JMLEqualsSet fast_insert(Object elem)
insert(Object)public JMLEqualsSet remove(Object elem)
has(Object),
insert(Object)public JMLEqualsSet intersection(JMLEqualsSet s2)
union(JMLEqualsSet),
difference(JMLEqualsSet)
public JMLEqualsSet union(JMLEqualsSet s2)
throws IllegalStateException
IllegalStateExceptionintersection(JMLEqualsSet),
difference(JMLEqualsSet)public JMLEqualsSet difference(JMLEqualsSet s2)
union(JMLEqualsSet),
difference(JMLEqualsSet)
public JMLEqualsSet powerSet()
throws IllegalStateException
IllegalStateExceptionpublic JMLEqualsBag toBag()
toSequence()public JMLEqualsSequence toSequence()
toBag(),
toArray()public Object[] toArray()
toSequence()public JMLEqualsSetEnumerator elements()
iterator()public JMLIterator iterator()
iterator in interface JMLCollectionelements()public String toString()
toString in class Object
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||