|
Section 8.16.1.2: $STRING |
|
This page contains the definition of the two generic $STRING abstract classes.
abstract class $STRING{ELT < $IS_EQ} < $STRINGS
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 ;
$STRING_ELT = set of object_type
state
multi : $STRING_ELT
inv multi_types ==
forall obj in set multi_types & sub_type($STRING_ELT,obj)
NOTE
|
See the important note about vdm state in the notes on vdm-sl usage in this specification.
|
This abstract class characterises the concept of all forms of simple string whether binary, text or other as sequences of the argument class (elements) which must sub-type from $IS_EQ. Classes which sub-type from this shall have immutable semantics!
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 ;
$STRING_ELT_FTP_STP = set of object_type
state
multi : $STRING_ELT_FTP_STP
inv multi_types ==
forall obj in set multi_types & sub_type($STRING_ELT_FTP_STP,obj)
NOTE
|
See the important note about vdm state in the notes on vdm-sl usage in this specification.
|
This abstract class characterises the concept of simple non-text strings as sequences of the argument class (elements) which must sub-type from $IS_EQ. The second and third class arguments are the 'corresponding' mutable ($FSTRINGS{ELT}) and immutable (sub-typing from this abstract class) string classes. Classes which sub-type from this class shall have immutable semantics!
acopy(
vals : STP
) ;
-- This routine copies the contents of vals into self either until the
-- last element of val has been copied or self is full.
copy : SAME ;
-- This routine returns an identical copy of self.
aget(
index : CARD
) : ELT ;
-- This routine returns the indexed element of the string.
plus(
elem : ELT
) : SAME ;
-- This returns the string formed by appending other (which must be of
-- the same class) to self. Either or both may be void.
plus(
str : STP
) : SAME ;
-- This returns the string formed by appending other (which must be of
-- the same class) to self. Either or both may be void.
plus(
str : FSTP
) : SAME ;
-- This returns the string formed by appending other (which must be of
-- the same class) to self. Either or both may be void.
is_empty : BOOL ;
-- This returns true if and only if self contains no elements.
is_prefix(
other : STP
) : BOOL ;
-- This predicate returns true if and only if other is identical to the
-- bit-pattern starting at the beginning of self.
count(
elem : ELT
) : CARD ;
-- This routine returns a count of the number of occurrences of the
-- value of elem in self.
search(
elem : ELT
) : CARD ;
-- This routine returns the index in self at which elem is first found
-- - or if not present then CARD::maxval.
search(
elem : ELT,
start : CARD
) : CARD ;
-- This routine returms the index in self at which elem is first found
-- at or after index start - or if not present then CARD::maxval.
search(
str : STP
) : CARD ;
-- This routine returns the index of the leftmost substring of self
-- which completely matches str. If there is no such position then
-- CARD::maxval is returned.
search(
str : STP,
start : CARD
) : CARD ;
-- This routine returns the index of the first appearance of the entire
-- string str in self starting from the index start. CARD::maxval is
-- returned if no such position is found.
search_backwards(
elem : ELT
) : CARD ;
-- This routine returns the index of the last occurrence of elem in
-- self -- or CARD::maxval if not found at all.
search_backwards(
elem : ELT,
start : CARD
) : CARD ;
-- This routine returns the index in self at which the bit-pattern elem
-- is first found starting to search backwards from index start. If not
-- found then CARD::maxval is returned.
mismatch(
other : STP
) : CARD ;
-- This routine returns the index of the first element of self which has
-- a different element value from other or CARD::maxval if self is a prefix
-- of other.
substring(
beg : CARD
) : SAME ;
-- This returns the substring consisting of all elements starting with
-- the one indexed by beg.
contains(
elem : ELT
) : BOOL ;
-- This routine returns true if and only if at leaat one of the elements
-- of self has the value elem, otherwise false.
reverse : SAME ;
-- This routine returns a string which has the value of self with all
-- elements in the reverse order.
elt!(
once beg : CARD
) : ELT ;
-- This iter yields each element of the string in sequence starting with
-- that indicated by the index beg.
elt!(
once beg,
once num : CARD
) : ELT ;
-- This iter yields num elements of self in sequence, starting with that
-- indicated by the index beg.
ind! : CARD ;
-- This iter yields all possible indices of self in turn.
chunk!(
chunk_size : CARD
) : SAME ;
-- This iter yields successive groups of elements of self, the length
-- of which is defined by the chunk_size parameter.
chunk!(
once start : CARD,
chunk_size : CARD
) : SAME ;
-- This iter yields successive groups of elements starting at start,
-- the length of which is defined by the chunk_size parameter.
Comments or enquiries should be made to
Keith
Hopper.
Page last modified:
Monday, 22 May 2000.
|
|