Package components.set
Interface SetKernel<T>
- Type Parameters:
T- type ofSetKernelelements
- All Known Subinterfaces:
Set<T>
- All Known Implementing Classes:
Set1L,Set2,Set3,Set4,SetSecondary
Set kernel component with primary methods. (Note: by package-wide convention,
all references are non-null.)
- Mathematical Model (abstract value and abstract invariant of this):
type SetKernel is modeled by finite set of T- Constructor(s) (initial abstract value(s) of this):
(): ensures this = {}- Iterator String (abstract value of ~this):
entries(~this.seen * ~this.unseen) = this and |~this.seen * ~this.unseen| = |this|
-
Method Summary
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface components.standard.Standard
clear, newInstance, transferFrom
-
Method Details
-
add
Addsxto this.- Parameters:
x- the element to be added- Aliases:
- reference
x - Updates:
this- Requires:
x is not in this- Ensures:
this = #this union {x}
-
remove
Removesxfrom this, and returns it.- Parameters:
x- the element to be removed- Returns:
- the element removed
- Updates:
this- Requires:
x is in this- Ensures:
this = #this \ {x} and remove = x
-
removeAny
Removes and returns an arbitrary element fromthis.- Returns:
- the element removed from
this - Updates:
this- Requires:
|this| > 0- Ensures:
removeAny is in #this and this = #this \ {removeAny}
-
contains
Reports whetherxis inthis.- Parameters:
x- the element to be checked- Returns:
- true iff element is in
this - Ensures:
contains = (x is in this)
-
size
int size()Reports size (cardinality) ofthis.- Returns:
- the number of elements in
this - Ensures:
size = |this|
-