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 output

2010-04-16 09:18 by benjk -
Changed lines 1-5 from:
[@DEFINITION MODULE SampleCollection;

(* Sample Collection Type *)

TYPE SampleCollection = OPAQUE ("A-Type"
);
to:
[@DEFINITION MODULE SampleCollection ("A-Type");

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

TYPE SampleCollection = OPAQUE
;
2010-04-16 05:59 by benjk -
Changed line 5 from:
TYPE SampleCollection = OPAQUE;
to:
TYPE SampleCollection = OPAQUE ("A-Type");
2010-04-12 09:29 by benjk -
Changed lines 10-12 from:
TYPE KeyType IS CARDINAL;

TYPE ValueType = ARRAY 255 OF
CHAR;
to:
TYPE KeyType IS CARDINAL; (* arbitrary type *)

TYPE ValueType = ARRAY 255 OF
CHAR; (* arbitrary type *)
2010-04-12 09:28 by benjk -
Changed line 12 from:
TYPE ValueType IS REAL;
to:
TYPE ValueType = ARRAY 255 OF CHAR;
2010-04-12 09:27 by benjk -
Changed line 10 from:
TYPE KeyType = CARDINAL;
to:
TYPE KeyType IS CARDINAL;
2010-04-12 09:26 by benjk -
Changed line 10 from:
TYPE KeyType = SET OF 4; (* 32 bit keys *)
to:
TYPE KeyType = CARDINAL;
2010-04-12 09:25 by benjk -
Added lines 8-14:
(* key and value type *)

TYPE KeyType = SET OF 4; (* 32 bit keys *)

TYPE ValueType 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 : SampleCollection ) : LONGCARD;
(* Returns the number of entries stored in dict *)

Deleted lines 51-54:
(* counter *)

PROCEDURE [COUNT] entryCount ( dict : SampleCollection ) : LONGCARD;
(* Returns the number of entries stored in dict *)
2010-04-09 18:31 by benjk -
Changed lines 18-19 from:
PROCEDURE [.] retrieveValue ( dict : SampleCollection; key : KeyType; VAR value : ValueType ) : BOOLEAN;
(* Searches for key in dict, passes its value back in value and returns TRUE if found, otherwise returns FALSE *)
to:
PROCEDURE [.] valueForKey ( dict : SampleCollection; key : KeyType; VAR found : BOOLEAN ) : ValueType;
(* 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 : SampleCollection; key : KeyType; VAR value : ValueType ) : BOOLEAN;
to:
PROCEDURE [.] retrieveValue ( dict : SampleCollection; key : KeyType; VAR value : ValueType ) : BOOLEAN;
2010-04-09 18:26 by benjk -
Changed lines 18-19 from:
PROCEDURE [.] valueForKey ( dict : SampleCollection; key : KeyType ) : ValueType;
(* Returns the value stored
for key in dict, returns NIL if no key is not present in dict *)
to:
PROCEDURE [.] valueForKey ( dict : SampleCollection; key : KeyType; VAR value : ValueType ) : 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 : SampleCollection; key : KeyType );
to:
PROCEDURE [-] removeValue ( dict : SampleCollection; key : KeyType );
2010-04-09 18:06 by benjk -
Added lines 25-27:

PROCEDURE [!] removeValue ( dict : SampleCollection; key : KeyType );
(* 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 : SampleCollection; key : ARRAY OF CHAR ) : ValueType;
to:
PROCEDURE [.] valueForKey ( dict : SampleCollection; key : KeyType ) : ValueType;
Changed line 11 from:
PROCEDURE [!] storeValue ( dict : SampleCollection; key : ARRAY OF CHAR; value : ValueType );
to:
PROCEDURE [!] storeValue ( dict : SampleCollection; key : KeyType; value : ValueType );
Changed line 14 from:
PROCEDURE [IN] keyExists ( dict : SampleCollection; key : ARRAY OF CHAR ) : BOOLEAN;
to:
PROCEDURE [IN] keyExists ( dict : SampleCollection; key : KeyType ) : BOOLEAN;
Changed line 17 from:
PROCEDURE [FOR] nextEntry ( dict : SampleCollection; VAR key : ARRAY OF CHAR; VAR value : ValueType );
to:
PROCEDURE [FOR] nextEntry ( dict : SampleCollection; VAR key : KeyType; VAR value : ValueType );
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 : SampleCollection; VAR key : ARRAY OF CHAR ) : ValueType;
(* 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 : SampleCollection; VAR key : ARRAY OF CHAR; VAR value : ValueType );
(* 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 : SampleCollection; key : ARRAY OF CHAR ) : ValueType;
(* 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 : SampleCollection; VAR key : ARRAY OF CHAR ) : ValueType;
(* 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 : SampleCollection );
to:
PROCEDURE [NEW] new ( VAR dict : SampleCollection );
(* 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 : SampleCollection; key : ARRAY OF CHAR ) : ValueType;
(* 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 : SampleCollection );
to:
(* Returns the number of entries stored in dict *)

PROCEDURE [DISPOSE] dispose ( VAR dict : SampleCollection )
;
(* 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.@]