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