Sather Home Page

Section 8.3.2.11:
CASE_MAPLET

immutable class CASE_MAPLET < $IS_EQ, $IMMUTABLE
$IS_EQ $BINARY $STR

Inheritance map

Formal Types

types

SAME = CASE_MAPLET ;
CASE_MAPLET = token ;

This class implements the concept of a one-to-one and onto mapping from a member of a sequence of codes to a corresponding member of another sequence of codes which are non-overlapping.


External specifications

The following feature is required to be implemented for this class in accordance with the specification given in $IS_EQ :-


The following features are required to be implemented for this class in accordance with the specifications given by inheritance in $STR of which $IMMUTABLE is a sub-type :-


The following features are required to be implemented for this class in accordance with the specifications given in $BINARY of which $IMMUTABLE is a sub-type:-


Reader Routines

This class has the following three reader routines -


create

This feature creates a maplet from the individual components providing the maplet is one-to-one and onto the domain of valid codes.

create (
code_base : CHAR_CODE,
off : INT,
cnt : CARD
) : SAME
Formal Signature
create(code_base : CHAR_CODE, off : INT, cnt : CARD) res : SAME
Pre-condition
pre CHAR_CODE.card(code_base) >= off
      and let valid_dom = dom CULTURE.rep_map(LIBCHARS.culture(CHAR_CODE.lib(code_base))) in
         let rng_base = CHAR_CODE.create(CHAR_CODE.card(code_base) + off, CHAR_CODE.lib(code_base) in
            let dom_seq = (code_base, ..., CHAR_CODE.offset(code_base, cnt)),
               rng_seq = (rng_base, ..., CHAR_CODE.offset(rng_base, cnt)) in
                  forall elem : CHAR_CODE | elem in set (dom dom_seq union dom rng_seq) &
                        elem in set valid_dom
                     and forall elem : CHAR_CODE | elem in set dom dom_seq &
                        elem not in set dom rng_seq
Post-condition
post true

This feature creates a new maplet from the argument values provided that all of the mappings and reverese mappings yield codes in the domain of the culture specified in the base code.


is_disjoint

This feature returns true if self and other have no common elements.

is_disjoint (
other : SAME
) : BOOL
Formal Signature
is_disjoint(self : SAME, other : SAME) res : BOOL
Pre-condition

Since neither argument is optional this pre-condition is vacuously true.

Post-condition
post res = let other_base = code_base(other) in
      let dom_seq = (code_base, ..., CHAR_CODE.offset(code_base, cnt)),
         other_seq = (other_base, ..., CHAR_CODE.offset(other_base, cnt(other))) in
            forall elem : CHAR_CODE | elem in set dom dom_seq &
                  elem not in set dom other_seq

This predicate returns true if and only if self and other have no elements in common!


in_range

This feature returns true if the given code is in the range of the mapping.

in_range (
chcode : CHAR_CODE
) : BOOL
Formal Signature
in_range(self : SAME, chcode : CHAR_CODE) res : BOOL
Pre-condition

Since neither argument is optional this pre-condition is vacuously true.

Post-condition
post res = let rng_base = CHAR_CODE.create(CHAR_CODE.card(code_base) + off,
              CHAR_CODE.lib(code_base) in
         let rng_seq = (rng_base, ..., CHAR_CODE.offset(rng_base, cnt)) in
            chcode not in set dom rng_seq

This predicate returns true if and only if the given code is in the range of this maplet.


in_domain

This feature returns true if the given code is in the domain of the mapping.

in_domain (
chcode : CHAR_CODE
) : BOOL
Formal Signature
in_domain(self : SAME, chcode : CHAR_CODE) res : BOOL
Pre-condition

Since neither argument is optional this pre-condition is vacuously true.

Post-condition
post res = let dom_seq = (code_base, ..., CHAR_CODE.offset(code_base, cnt)) in
         chcode not in set dom dom_seq

This predicate returns true if and only if the given code is in the domain of this maplet.


reverse_map

This feature returns the character code in the domain mapped from the given code in the range of this maplet

reverse_map (
upcode : CHAR_CODE
) : BOOL
Formal Signature
reverse_map(self : SAME, upcode : CHAR_CODE) res : BOOL
Pre-condition
pre in_range(self,upcode)
Post-condition
post res = CHAR_CODE.offset(upcode,- off)

This feature returns the code on the domain of this maplet corresponding to the given code in the range.


map

This feature returns the character code in the range mapped from the given code in the domain of this maplet

map (
lowcode : CHAR_CODE
) : BOOL
Formal Signature
map(self : SAME, lowcode : CHAR_CODE) res : BOOL
Pre-condition
pre in_domain(self,lowcode)
Post-condition
post res = CHAR_CODE.offset(lowcode,off)

This feature returns the code in the range of this maplet corresponding to the given code in the domain.


Language Index Library Index Codes Index
Comments or enquiries should be made toKeith Hopper.
Page last modified: Monday, 23 April 2001.
Produced with Amaya