org.jmlspecs.samples.sets
Class IntegerSetAsHashSet
java.lang.Object
org.jmlspecs.samples.sets.IntegerSetAsHashSet
- All Implemented Interfaces:
- IntegerSetInterface
- public class IntegerSetAsHashSet
- extends Object
- implements IntegerSetInterface
A set of integers as a HashSet.
- Author:
- Katie Becker, Gary T. Leavens
Class Specifications |
private represents theSet <- this.abstractValue(); |
Specifications inherited from class Object |
represents objectState <- org.jmlspecs.lang.JMLDataGroup.IT;
public represents _getClass <- \typeof(this); |
Specifications inherited from interface IntegerSetInterface |
instance public invariant_redundantly this.theSet != null;
instance public invariant ( \forall org.jmlspecs.models.JMLType e; this.theSet.has(e); e instanceof org.jmlspecs.models.JMLInteger);
public initially this.theSet.isEmpty(); |
Method Summary |
void |
insert(int i)
Insert the given integer into this set. |
boolean |
isMember(int i)
Tell if the argument is in this set. |
void |
remove(int i)
Remove the given integer from this set. |
String |
toString()
|
hset
private HashSet hset
- Specifications: non_null
is in groups: theSet
maps hset.theSet \into theSet
IntegerSetAsHashSet
public IntegerSetAsHashSet()
- Initialize this set to be the empty set.
- Specifications:
-
public normal_behavior
assignable theSet;
ensures this.theSet != null&&this.theSet.isEmpty();
abstractValue
private JMLValueSet abstractValue()
- Return the abstract value of this IntegerSetAsHashSet.
- Specifications: pure
isMember
public boolean isMember(int i)
- Description copied from interface:
IntegerSetInterface
- Tell if the argument is in this set.
- Specified by:
isMember
in interface IntegerSetInterface
- Specifications: pure
- Specifications inherited from overridden method isMember(int elem) in interface IntegerSetInterface:
pure -
public normal_behavior
ensures \result == this.theSet.has(new org.jmlspecs.models.JMLInteger(elem));
insert
public void insert(int i)
- Description copied from interface:
IntegerSetInterface
- Insert the given integer into this set.
- Specified by:
insert
in interface IntegerSetInterface
- Specifications inherited from overridden method insert(int elem) in interface IntegerSetInterface:
-
public normal_behavior
assignable theSet;
ensures this.theSet.equals(\old(this.theSet.insert(new org.jmlspecs.models.JMLInteger(elem))));
remove
public void remove(int i)
- Description copied from interface:
IntegerSetInterface
- Remove the given integer from this set.
- Specified by:
remove
in interface IntegerSetInterface
- Specifications inherited from overridden method remove(int elem) in interface IntegerSetInterface:
-
public normal_behavior
assignable theSet;
ensures this.theSet.equals(\old(this.theSet.remove(new org.jmlspecs.models.JMLInteger(elem))));
toString
public String toString()
- Overrides:
toString
in class Object
- Specifications inherited from overridden method in class Object:
non_null -
public normal_behavior
assignable objectState;
ensures \result != null&&\result .equals(this.theString);
ensures (* \result is a string representation of this object *);
- also
-
public code normal_behavior
assignable \nothing;
ensures \result != null&&(* \result is the instance's class name, followed by an @, followed by the instance's hashcode in hex *);
- also
-
public code model_program { ... }
- implies_that
-
assignable objectState;
ensures \result != null;
JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.