| # Section 8.1.1.11: $ELT |

The following abstract type ($ELT) is the first of two with this name. The second one is $ELT{T}. Both are defined on this page.

###### abstract class $ELT

#### Formal Definitions

This abstract class defines a state component which is a set of all instantiations of objects of any class sub-typing from this class in addition to the vdm model types used wherever this class name is used. Note that SAME has to be an instantiated class, not an abstract one.

types
SAME = object_type ;
$ELT = set of object_type
state
multi : $ELT
inv multi_types ==
forall obj in set multi_types & sub_type($ELT,obj)

NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification.

This abstract class defines the concept of an object which contains a nnumber of other objects of an arbitrary type. It defines two features.

#### size

This feature is provided to return the count of elements in the sub-typing class.

size | CARD

##### Formal Signature

size(self : SAME) res : CARD

##### Pre-condition

Note that in contrast to a pre-condition written in Sather source code, in vdm-sl the type SAME is not an optional type and therefore self must exist, leading to the pre-condition being vacuously true.

##### Post-condition

post res = card elems self

This feature returns the count of elements in self. Note that this may be zero since, while self may exist it does not necessarily have to contain anything.

#### elt!

This feature yields in turn all of the values of the components of the object in an implementation-dependent order. The underlying implementation is entitled to change this order at any time, so it should not be relied upon.

Note that this feature requirement differs from the more stringent requirement of array iterators.

elt! | $OB

##### Formal Signature

Note that the formal name of the iter has been changed to replace the exclamation mark iter symbol to a name acceptable to vdm tools.

elt_iter(self : SAME) yld : $OB

Pre-condition

Note that, in contrast to a pre-condition written in Sather source code, in vdm-sl the type SAME is not an optional type and therefore self must exist, leading to the vacuous pre-condition - true.

Post-condition

This post-condition makes use of the history concept from vdm++ (see the vdm dialect notes).

post ((history~ = [])
or (yld = self(card elems history~ + 1)))
and (history = history~ ^ yld)

Quit condition

For quit actions see the specificatiion of the quit statement.

errs QUIT : (elems, history~ = elems self) -> quit

This iterator yields successive elements of self without duplication in any order until all have been returned, when the iterator quits.

###### abstract class $ELT{T}

#### Formal Definitions

This abstract class defines a state component which is a set of all instantiations of objects of any class sub-typing from this class in addition to the vdm model types used wherever this class name is used. Note that SAME has to be an instantiated class, not an abstract one.

types
SAME = object_type ;
$ELT_T = set of object_type
state
multi : $ELT_T
inv multi_types ==
forall obj in set multi_types typeof(obj) = T

NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification.

This abstract class defines the concept of an object which contains a nnumber of other objects of an arbitrary type. Inheriting from $ELT, it defines only the single iterator since the size feature requirement is inherited.

#### elt!

This feature yields in turn all of the values of the components of the object in an implementation-dependent order. The underlying implementation is entitled to change this order at any time, so it should not be relied upon.

Note that this feature requirement differs from the more stringent requirement of array iterators.

elt! | T

##### Formal Signature

Note that the formal name of the iter has been changed to replace the exclamation mark iter symbol to a name acceptable to vdm tools.

elt_iter(self : SAME) yld : T

##### Pre-condition

Note that, in contrast to a pre-condition written in Sather source code, in vdm-sl the type SAME is not an optional type and therefore self must exist, leading to the pre-condition being vacuously true.

##### Post-condition

This post-condition makes use of the history concept from vdm++ (see the vdm dialect notes).

post ((history~ = [])
or (yld = self(card elems history~ + 1)))
and (history = history~ ^ yld)

Quit condition

For quit actions see the specificatiion of the quit statement.

errs QUIT : (elems history~ = elems self) -> quit

This iterator yields successive elements of self (which are of the type of the argument to this class) in any order until all have been returned when the iterator quits.

| Language Index |  | Library Index |  | Basic Index

Comments or enquiries should be made to Keith Hopper. Page last modified: Tuesday, 23 May 2000. |