![]() |
Section 8.12.1.24:
|
![]() |
Inheritance Diagram
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 ; $STREAM = set of object_type state references : $STREAM inv ref_types == forall obj | obj in set ref_types & sub_type($STREAM,obj)
NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification. |
This abstraction specifies a stream of values which model the source of unique values in the domain of the argument type, no value being repeated.
This creation operation produces a new stream object of the given type for which the first value to be yielded/returned id the argument value - which may not be nil!
create | ( |
start_val : ETP | |
) : SAME |
create(start_val : ETP) res : SAME
pre not (start_val = ETP.nil)
post res.history = [start_val]
This creation operation returns a new stream for which the first value to be returned by the feature next will be the given argument value.
This requirement provides a facility to return the next value in sequence after the one most recently returned - irrespective of other calls on this stream object.
next | : ETP |
next(self : SAME) res : ETP
Note that, in contrast to a pre-condition written in Sather source code, in vdm-sl the type ETP is not an optional type and therefore self must exist, leading to the vacuous pre-condition - true.
Providing that the last value in the sequence has not already been produced, this returns the next in sequence after the previous one, otherwise nil.
Note that the use of the history sequence is necessary to define this routine just as if it were an iter!
post len history~ = 1 and res = history~(1) and history = [ETP.nil] ^ history~ or res > history(len history~) and history = history~ ^ res
This feature returns the next unique value in the class ETP, irrespective of the use of the iter defined below.
This feature yields in turn all of the values of the type argument class in ascending order without duplication of any already yielded or returned.
next! | : ETP |
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.
next_iter(self : SAME) yld : ETP
Note that, in contrast to a pre-condition written in Sather source code, in vdm-sl the type ETP is not an optional type and therefore self must exist, leading to the vacuous pre-condition - true.
This post-condition makes use of the history concept from vdm++ (see the vdm dialect notes).
post len history~ = 1 and res = history~(1) and history = [ETP.nil] ^ history~ or res > history(len history~) and history = history~ ^ res
For quit actions see the specificatiion of the quit statement.
errs QUIT : (history~(0) = history~(len history~)) -> quit
This iterator yields successive values of the type argument class without duplication in any order until all have been returned, when the iterator quits.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Numeric Index |
Comments
or enquiries should be made toKeith Hopper. Page last modified:Thursday, 31 May 2001. |
![]() |