|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jmlspecs.models.JMLEqualsBag
Bags (i.e., multisets) of objects. This type uses ".equals" to compare elements, and does not clone elements that are passed into and returned from the bag's methods.
JMLCollection,
JMLType,
JMLObjectBag,
JMLValueBag,
JMLEqualsBagEnumerator,
JMLObjectSet,
JMLValueSet| Field Summary | |
static JMLEqualsBag |
EMPTY
The empty JMLEqualsBag. |
protected int |
size
The size of this bag. |
protected JMLEqualsBagEntryNode |
the_list
The list representing the contents of this bag. |
| Constructor Summary | |
|
JMLEqualsBag()
An equational specification of the properties of bags. |
|
JMLEqualsBag(Object elem)
Initialize this bag to contain the given element. |
protected |
JMLEqualsBag(JMLEqualsBagEntryNode ls,
int sz)
Initialize this bag with the given representation. |
| 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 bag. |
static JMLEqualsBag |
convertFrom(Object[] a)
Return the bag containing all the elements in the given array. |
static JMLEqualsBag |
convertFrom(Collection c)
Return the bag containing all the object in the given collection. |
static JMLEqualsBag |
convertFrom(JMLCollection c)
Return the bag containing all the object in the given JMLCollection. |
int |
count(Object elem)
Tell how many times the given element occurs ".equals" to an element in this bag. |
JMLEqualsBag |
difference(JMLEqualsBag b2)
Return a bag containing the items in this bag minus the items in the given bag. |
JMLEqualsBagEnumerator |
elements()
Returns an Enumeration over this bag. |
boolean |
equals(Object b2)
Test whether this object's value is equal to the given argument. |
protected JMLEqualsBagEntry |
getMatchingEntry(Object item)
Find a JMLEqualsBagEntry that is for the same element, if possible. |
boolean |
has(Object elem)
Tell whether the given element occurs ".equals" to an element in this bag. |
int |
hashCode()
Return a hash code for this object |
JMLEqualsBag |
insert(Object elem)
Return a bag containing the given item and the ones in this bag. |
JMLEqualsBag |
insert(Object elem,
int cnt)
Return a bag containing the given item the given number of times, in addition to the ones in this bag. |
int |
int_size()
Tell the number of elements in this bag. |
JMLEqualsBag |
intersection(JMLEqualsBag b2)
Return a bag containing the items in both this bag and the given bag. |
boolean |
isEmpty()
Tell whether this bag has no elements. |
boolean |
isProperSubbag(JMLEqualsBag b2)
Tells whether every item in this bag is contained in the argument, but the argument is strictly larger. |
boolean |
isProperSuperbag(JMLEqualsBag b2)
Tells whether every item in the argument is contained in this bag argument, but this bag is strictly larger. |
boolean |
isSubbag(JMLEqualsBag b2)
Tells whether every item in this bag is contained in the argument. |
boolean |
isSuperbag(JMLEqualsBag b2)
Tells whether every item in the argument is contained in this bag. |
JMLIterator |
iterator()
Returns an iterator over this bag. |
JMLEqualsBag |
remove(Object elem)
Return a bag containing the items in this bag except for one of the given element. |
JMLEqualsBag |
remove(Object elem,
int cnt)
Return a bag containing the items in this bag, except for the given number of the given element. |
JMLEqualsBag |
removeAll(Object elem)
Return a bag containing the items in this bag, except for all items that are ".equals" to the given item. |
static JMLEqualsBag |
singleton(Object e)
Return the singleton bag containing the given element. |
Object[] |
toArray()
Return a new array containing all the elements of this. |
JMLEqualsSequence |
toSequence()
Return a new JMLEqualsSequence containing all the elements of this. |
JMLEqualsSet |
toSet()
Return a new JMLEqualsSet containing all the elements of this. |
String |
toString()
Return a string representation of this object. |
JMLEqualsBag |
union(JMLEqualsBag b2)
Return a bag containing the items in either this bag or the given bag. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected final JMLEqualsBagEntryNode the_list
protected final int size
public static final JMLEqualsBag EMPTY
JMLEqualsBag()| Constructor Detail |
public JMLEqualsBag()
EMPTYpublic JMLEqualsBag(Object elem)
elem - the element that is the sole contents of this bag.singleton(java.lang.Object)
protected JMLEqualsBag(JMLEqualsBagEntryNode ls,
int sz)
| Method Detail |
public static JMLEqualsBag singleton(Object e)
JMLEqualsBag(Object)public static JMLEqualsBag convertFrom(Object[] a)
public static JMLEqualsBag convertFrom(Collection c)
throws ClassCastException
ClassCastException - if some element in c is not an instance of
Object.containsAll(java.util.Collection)
public static JMLEqualsBag convertFrom(JMLCollection c)
throws ClassCastException
ClassCastException - if some element in c is not an instance of
Object.public int count(Object elem)
elem - the element sought.
has(Object)public boolean has(Object elem)
has in interface JMLCollectionelem - the element sought.count(Object)public boolean containsAll(Collection c)
c - the collection whose elements are sought.#isSuperbag(JMLEqualsSet),
convertFrom(java.util.Collection)public boolean equals(Object b2)
Note that the elementTypes may be different for otherwise equal bags.
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 isSubbag(JMLEqualsBag b2)
isProperSubbag(JMLEqualsBag),
isSuperbag(JMLEqualsBag)public boolean isProperSubbag(JMLEqualsBag b2)
isSubbag(JMLEqualsBag),
isProperSuperbag(JMLEqualsBag)public boolean isSuperbag(JMLEqualsBag b2)
isProperSuperbag(JMLEqualsBag),
isSubbag(JMLEqualsBag),
containsAll(java.util.Collection)public boolean isProperSuperbag(JMLEqualsBag b2)
isSuperbag(JMLEqualsBag),
isProperSubbag(JMLEqualsBag)
public Object choose()
throws JMLNoSuchElementException
JMLNoSuchElementException - if this is empty.isEmpty(),
elements()public Object clone()
clone in interface JMLTypeclone in class Objectprotected JMLEqualsBagEntry getMatchingEntry(Object item)
item - the item sought.
public JMLEqualsBag insert(Object elem)
throws IllegalStateException
IllegalStateExceptioninsert(Object, int),
has(Object),
remove(Object)
public JMLEqualsBag insert(Object elem,
int cnt)
throws IllegalArgumentException,
IllegalStateException
IllegalArgumentException
IllegalStateExceptioninsert(Object),
has(Object),
remove(Object, int)public JMLEqualsBag remove(Object elem)
remove(Object, int),
insert(Object)
public JMLEqualsBag remove(Object elem,
int cnt)
throws IllegalArgumentException
IllegalArgumentExceptionremove(Object),
insert(Object, int)public JMLEqualsBag removeAll(Object elem)
remove(Object),
remove(Object, int)public JMLEqualsBag intersection(JMLEqualsBag b2)
union(JMLEqualsBag),
difference(JMLEqualsBag)public JMLEqualsBag union(JMLEqualsBag b2)
intersection(JMLEqualsBag),
difference(JMLEqualsBag)public JMLEqualsBag difference(JMLEqualsBag b2)
union(JMLEqualsBag),
difference(JMLEqualsBag)public JMLEqualsSequence toSequence()
toArray(),
toSet()public JMLEqualsSet toSet()
toSequence()public Object[] toArray()
toSequence()public JMLEqualsBagEnumerator 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 | ||||||||||