Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Type Sample Collection

WiP.TypeSampleCollection History

Hide minor edits - Show changes to markup

2010-04-16 09:18 by benjk -
Changed lines 1-5 from:

[@DEFINITION MODULE Sample Collection?;

(* Sample Collection Type *)

TYPE Sample Collection? = OPAQUE ("A-Type");

to:

[@DEFINITION MODULE Sample Collection? ("A-Type");

(* Example library for a collection using operator bindings *)

TYPE Sample Collection? = OPAQUE;

2010-04-16 05:59 by benjk -
Changed line 5 from:

TYPE Sample Collection? = OPAQUE;

to:

TYPE Sample Collection? = OPAQUE ("A-Type");

2010-04-12 09:29 by benjk -
Changed lines 10-12 from:

TYPE Key Type? IS CARDINAL;

TYPE Value Type? = ARRAY 255 OF CHAR;

to:

TYPE Key Type? IS CARDINAL; (* arbitrary type *)

TYPE Value Type? = ARRAY 255 OF CHAR; (* arbitrary type *)

2010-04-12 09:28 by benjk -
Changed line 12 from:

TYPE Value Type? IS REAL;

to:

TYPE Value Type? = ARRAY 255 OF CHAR;

2010-04-12 09:27 by benjk -
Changed line 10 from:

TYPE Key Type? = CARDINAL;

to:

TYPE Key Type? IS CARDINAL;

2010-04-12 09:26 by benjk -
Changed line 10 from:

TYPE Key Type? = SET OF 4; (* 32 bit keys *)

to:

TYPE Key Type? = CARDINAL;

2010-04-12 09:25 by benjk -
Added lines 8-14:

(* key and value type *)

TYPE Key Type? = SET OF 4; (* 32 bit keys *)

TYPE Value Type? IS REAL;

Changed line 17 from:

CONST [NIL] nullKey = NIL;

to:

CONST [NIL] nullKey = 0;

2010-04-11 15:58 by benjk -
Added line 23:
2010-04-11 15:57 by benjk -
Added line 7:
Added line 12:
Added line 18:
Changed lines 24-25 from:

(* mutator *)

to:

(* mutators *)

Added line 32:
Added lines 38-44:

(* counter *)

PROCEDURE [COUNT] entryCount ( dict : Sample Collection? ) : LONGCARD; (* Returns the number of entries stored in dict *)

Deleted lines 51-54:

(* counter *)

PROCEDURE [COUNT] entryCount ( dict : Sample Collection? ) : LONGCARD; (* Returns the number of entries stored in dict *)

2010-04-09 18:31 by benjk -
Changed lines 18-19 from:

PROCEDURE [.] retrieveValue ( dict : Sample Collection?; key : Key Type?; VAR value : Value Type? ) : BOOLEAN; (* Searches for key in dict, passes its value back in value and returns TRUE if found, otherwise returns FALSE *)

to:

PROCEDURE [.] valueForKey ( dict : Sample Collection?; key : Key Type?; VAR found : BOOLEAN ) : Value Type?; (* Searches for key in dict, if found passes TRUE in found and returns its value, otherwise passes FALSE *)

2010-04-09 18:28 by benjk -
Changed line 18 from:

PROCEDURE [.] valueForKey ( dict : Sample Collection?; key : Key Type?; VAR value : Value Type? ) : BOOLEAN;

to:

PROCEDURE [.] retrieveValue ( dict : Sample Collection?; key : Key Type?; VAR value : Value Type? ) : BOOLEAN;

2010-04-09 18:26 by benjk -
Changed lines 18-19 from:

PROCEDURE [.] valueForKey ( dict : Sample Collection?; key : Key Type? ) : Value Type?; (* Returns the value stored for key in dict, returns NIL if no key is not present in dict *)

to:

PROCEDURE [.] valueForKey ( dict : Sample Collection?; key : Key Type?; VAR value : Value Type? ) : BOOLEAN; (* Searches for key in dict, passes its value back in value and returns TRUE if found, otherwise returns FALSE *)

2010-04-09 18:07 by benjk -
Changed line 26 from:

PROCEDURE [!] removeValue ( dict : Sample Collection?; key : Key Type? );

to:

PROCEDURE [-] removeValue ( dict : Sample Collection?; key : Key Type? );

2010-04-09 18:06 by benjk -
Added lines 25-27:

PROCEDURE [!] removeValue ( dict : Sample Collection?; key : Key Type? ); (* Removes the entry whose key is key from dict *)

2010-04-09 18:00 by benjk -
Added lines 7-10:

(* null key *)

CONST [NIL] nullKey = NIL;

Changed lines 35-36 from:
   If the invalid key is passed in then the first key/value pair is passed back in key and value.
   If no successor key is found then the invalid key is passed back in key and value is undefined. *)
to:
   If the null key is passed in then the first key/value pair is passed back in key and value.
   If no successor key is found then the null key is passed back in key and value is undefined. *)
2010-04-09 17:57 by benjk -
Changed line 31 from:
   If the invalid passed in for key then the first key/value pair is passed back in key and value.
to:
   If the invalid key is passed in then the first key/value pair is passed back in key and value.
2010-04-09 17:55 by benjk -
Changed lines 31-32 from:
   If the empty string is passed in for key then the first key/value pair is passed back in key and value.
   If no successor key is found then the empty string is passed back in key and value is undefined. *)
to:
   If the invalid passed in for key then the first key/value pair is passed back in key and value.
   If no successor key is found then the invalid key is passed back in key and value is undefined. *)
2010-04-09 17:54 by benjk -
Changed line 32 from:
   If no successor key is found then the empty string is passed back in key and no value is passed in value. *)
to:
   If no successor key is found then the empty string is passed back in key and value is undefined. *)
2010-04-09 17:49 by benjk -
Added lines 3-4:

(* Sample Collection Type *)

Added lines 7-8:

(* allocator *)

Added lines 12-13:

(* accessor *)

Added lines 17-18:

(* mutator *)

Added lines 22-23:

(* membership test *)

Added lines 27-28:

(* iterator *)

Added lines 34-35:

(* counter *)

Added lines 38-39:

(* destructor *)

2010-04-09 17:48 by benjk -
Changed line 8 from:

PROCEDURE [.] valueForKey ( dict : Sample Collection?; key : ARRAY OF CHAR ) : Value Type?;

to:

PROCEDURE [.] valueForKey ( dict : Sample Collection?; key : Key Type? ) : Value Type?;

Changed line 11 from:

PROCEDURE [!] storeValue ( dict : Sample Collection?; key : ARRAY OF CHAR; value : Value Type? );

to:

PROCEDURE [!] storeValue ( dict : Sample Collection?; key : Key Type?; value : Value Type? );

Changed line 14 from:

PROCEDURE [IN] keyExists ( dict : Sample Collection?; key : ARRAY OF CHAR ) : BOOLEAN;

to:

PROCEDURE [IN] keyExists ( dict : Sample Collection?; key : Key Type? ) : BOOLEAN;

Changed line 17 from:

PROCEDURE [FOR] nextEntry ( dict : Sample Collection?; VAR key : ARRAY OF CHAR; VAR value : Value Type? );

to:

PROCEDURE [FOR] nextEntry ( dict : Sample Collection?; VAR key : Key Type?; VAR value : Value Type? );

2010-04-09 17:44 by benjk -
Changed line 18 from:

(* Finds the successor key of key and passes its key/value pair back in key and value..

to:

(* Finds the successor key of key and passes its key/value pair back in key and value.

2010-04-09 17:44 by benjk -
Changed line 20 from:
   If no successor key is present in dict then the empty string is passed back in key and no value is passed in value *)
to:
   If no successor key is found then the empty string is passed back in key and no value is passed in value. *)
2010-04-09 17:42 by benjk -
Changed lines 17-20 from:

PROCEDURE [FOR] nextEntry ( dict : Sample Collection?; VAR key : ARRAY OF CHAR ) : Value Type?; (* Finds the successor key of key, passes the successor key back in key and returns its value.

   If the empty string is passed in for key then the first key is passed back and its value returned.
   If no successor key is present in dict then the empty string is passed back and NIL is returned *)
to:

PROCEDURE [FOR] nextEntry ( dict : Sample Collection?; VAR key : ARRAY OF CHAR; VAR value : Value Type? ); (* Finds the successor key of key and passes its key/value pair back in key and value..

   If the empty string is passed in for key then the first key/value pair is passed back in key and value.
   If no successor key is present in dict then the empty string is passed back in key and no value is passed in value *)
2010-04-09 17:39 by benjk -
Changed lines 19-20 from:
    If the empty string is passed in for key then the first key is passed back and its value returned.
    If no successor key is present in dict then the empty string is passed back and NIL is returned *)
to:
   If the empty string is passed in for key then the first key is passed back and its value returned.
   If no successor key is present in dict then the empty string is passed back and NIL is returned *)
2010-04-09 17:38 by benjk -
Changed line 20 from:
    If no successor key is present then the empty string is passed back and NIL is returned *)
to:
    If no successor key is present in dict then the empty string is passed back and NIL is returned *)
2010-04-09 17:38 by benjk -
Changed lines 18-20 from:

(* Finds the successor key of key, passes the successor key back in key and returns its value. If the empty string is passed

    in for key then the first key is passed back and its value returned.
    If no successor key is present then the empty string is passed back  *)
to:

(* Finds the successor key of key, passes the successor key back in key and returns its value.

    If the empty string is passed in for key then the first key is passed back and its value returned.
    If no successor key is present then the empty string is passed back and NIL is returned *)
2010-04-09 17:37 by benjk -
Changed lines 17-19 from:

PROCEDURE [FOR] nextEntry ( dict : Sample Collection?; key : ARRAY OF CHAR ) : Value Type?; (* Returns the value of the first entry of dict if key is the empty string, otherwise returns the

   value of the entry whose key is following key. Returns NIL if key represents the last entry in dict. *)
to:

PROCEDURE [FOR] nextEntry ( dict : Sample Collection?; VAR key : ARRAY OF CHAR ) : Value Type?; (* Finds the successor key of key, passes the successor key back in key and returns its value. If the empty string is passed

    in for key then the first key is passed back and its value returned.
    If no successor key is present then the empty string is passed back  *)
2010-04-09 17:25 by benjk -
Changed lines 18-19 from:

(* Returns the value of the first entry of dict if key is the empty string, otherwise returns the value of

   the entry whose key is following key. Returns NIL if key represents the last entry in dict. *)
to:

(* Returns the value of the first entry of dict if key is the empty string, otherwise returns the

   value of the entry whose key is following key. Returns NIL if key represents the last entry in dict. *)
2010-04-09 17:25 by benjk -
Changed line 19 from:
   the entry whose key is following key. Returns NIL if key is the last key in dict. *)
to:
   the entry whose key is following key. Returns NIL if key represents the last entry in dict. *)
2010-04-09 17:23 by benjk -
Changed lines 18-19 from:

(* Returns the first entry of dict if key is the empty string, otherwise returns the entry following key *)

to:

(* Returns the value of the first entry of dict if key is the empty string, otherwise returns the value of

   the entry whose key is following key. Returns NIL if key is the last key in dict. *)
2010-04-09 17:20 by benjk -
Changed lines 5-6 from:

PROCEDURE [NEW] new ( dict : Sample Collection? );

to:

PROCEDURE [NEW] new ( VAR dict : Sample Collection? ); (* Allocates a new collection and passes a reference to it back in dict *)

Changed lines 9-10 from:
to:

(* Returns the value stored for key in dict, returns NIL if no key is not present in dict *)

Changed lines 12-13 from:
to:

(* Stores value for key in dict, overwrites the previous value if key is already present in dict *)

Changed lines 15-19 from:
to:

(* Returns TRUE if key is present in dict, otherwise returns FALSE *)

PROCEDURE [FOR] nextEntry ( dict : Sample Collection?; key : ARRAY OF CHAR ) : Value Type?; (* Returns the first entry of dict if key is the empty string, otherwise returns the entry following key *)

Changed lines 21-22 from:

PROCEDURE [DISPOSE] dispose ( dict : Sample Collection? );

to:

(* Returns the number of entries stored in dict *)

PROCEDURE [DISPOSE] dispose ( VAR dict : Sample Collection? ); (* Deallocates dict and passes NIL back in dict *)

2010-04-09 15:16 by benjk -
Added lines 1-17:
DEFINITION MODULE SampleCollection;

TYPE SampleCollection = OPAQUE;

PROCEDURE [NEW] new ( dict : SampleCollection );

PROCEDURE [.] valueForKey ( dict : SampleCollection; key : ARRAY OF CHAR ) : ValueType;

PROCEDURE [!] storeValue ( dict : SampleCollection; key : ARRAY OF CHAR; value : ValueType );

PROCEDURE [IN] keyExists ( dict : SampleCollection; key : ARRAY OF CHAR ) : BOOLEAN;

PROCEDURE [COUNT] entryCount ( dict : SampleCollection ) : LONGCARD;

PROCEDURE [DISPOSE] dispose ( dict : SampleCollection );

END SampleCollection.