Lisaac prototype interface

Section Header
+ name := SET[E];
- comment := "Definition of a mathematical set of objects.";
All common operations on mathematical sets are available.
Well knowned implementations are HASHED_SET and AVL_SET.
Section Inherit
+ parent_traversable:TRAVERSABLE[E] :=
+ parent_safe_equal:SAFE_EQUAL[E] :=
Section Public
Counting:
- count:INTEGER <-
Cardinality of the set (i.e. actual `count' of stored elements).
- is_empty:BOOLEAN <-
Is the set empty?
Adding and removing:
- add e:E <-
Add new item `e' to the set. The mathematical definition of adding
in a set is followed, i.e. the element `e' is added only and only
if it is not yet present in the set.
As this `add' feature is actually using `is_equal', you may consider
to use `fast_add' for expanded objects as well while trying to get
the very best performances.
- fast_add e:E <-
Same job as `add', but uses basic `=' for comparison.
- remove e:E <-
Remove item `e' from the set: the mathematical definition of
removing from a set is followed.
- fast_remove e:E <-
Same job as `remove', but uses basic `=' for comparison.
- clear <-
- clear_count <-
Empty the current set (`is_empty' is True after that call).
If possible, the actual implementation is supposed to keep
its internal storage area in order to refill `Current' in
an efficient way.
See also `clear_count_and_capacity' to select the most appropriate.
- clear_count_and_capacity <-
Empty the current set (`is_empty' is True after that call).
If possible, the actual implementation is supposed to release
its internal storage area for this memory to be used by other objects.
See also `clear_count' to select the most appropriate.
Looking and searching:
- has e:E :BOOLEAN <-
Is element `e' in the set?
As this query is actually using `is_equal', you may consider to use
`fast_has' for expanded objects as well while trying to get the very
best performances.
- fast_has e:E :BOOLEAN <-
Is element `e' actually stored in the set?
Warning: this query is using basic `=' for comparison.
See also `has' when dealing with reference types.
- reference_at e:E :E <-
Non Void when `e' is in the set. In such a situation, `Result' is the
object which is actually stored in the `Current' set (see ensure assertion).
To provide iterating facilities:
- lower:INTEGER :=
- upper:INTEGER <-
- item i:INTEGER :E <-
Item at the corresponding index `i'.
See also `lower', `upper', `valid_index'.
SETs are intrinsically unordered, so there is no guarantee that
`item'(i) after performing an `add' or `remove' operation is related
in any way to `item'(i) before that operation.
- first:E <-
The very `first' item.
See also `last', `item'.
SETs are intrinsically unordered, so there is no guarantee that
`first' after performing an `add' or `remove' operation is related
in any way to `first' before that operation.
- last:E <-
The `last' item.
See also `first', `item'.
SETs are intrinsically unordered, so there is no guarantee that
`last' after performing an `add' or `remove' operation is related
in any way to `last' before that operation.
Mathematical operations:
- union other:SELF <-
Make the union of the `Current' set with `other'.
- '+' other:SELF :SELF <-
Return the union of the `Current' set with `other'.
- intersection other:SELF <-
Make the intersection of the `Current' set with `other'.
- '^' other:SELF :SELF <-
Return the intersection of the `Current' set with `other'.
- minus other:SELF <-
Make the set `Current' - `other'.
- '-' other:SELF :SELF <-
Return the set `Current' - `other'.
Comparison:
- is_subset_of other:SELF :BOOLEAN <-
Is the `Current' set a subset of `other'?
- is_disjoint_from other:SELF :BOOLEAN <-
Is the `Current' set disjoint from `other' ?
- '==' other:SELF :BOOLEAN <-
Is the `Current' set equal to `other'?
Duplication.
- copy other:SELF <-
Copy 'other' into the current set
- from_collection model:COLLECTION[E] <-
Add all items of `model'.
Agents based features:
- do_all action:BLOCK <-
Apply `action' to every item of `Self'.
See also `for_all', `exists'.
- for_all predicate:BLOCK :BOOLEAN <-
Do all items satisfy `predicate'?
See also `do_all', `exists'.
- exists predicate:BLOCK :BOOLEAN <-
Does at least one item satisfy `predicate'?
See also `do_all', `for_all'.
Creation.
- create:SELF <-
- make <-
Creation of an empty SET.