DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T V ┃
Length: 11910 (0x2e86) Types: TextFile Names: »V«
└─⟦85b835f43⟧ Bits:30000549 8mm tape, Rational 1000, Xlib rev 6.00 └─ ⟦0c20f784e⟧ »DATA« └─⟦1abbe589f⟧ └─⟦591c5b094⟧ └─⟦this⟧
with Arithmetic; use Arithmetic; with Vstring_Type; use Vstring_Type; generic ------------------------------------------------------------------------------ -- Copyright 1989 - 1991 by Rational, Santa Clara, California. -- -- All Rights Reserved. -- -- Permission to use, copy, modify, and distribute this software and its -- documentation for any purpose and without fee is hereby granted, -- provided that the above copyright notice(s) appear in all copies and that -- both that copyright notice(s) and this permission notice appear in -- supporting documentation, and that the name of Rational not be used in -- advertising or publicity pertaining to distribution of the software -- without specific, written prior permission. -- -- Rational disclaims all warranties with regard to this software, including -- all implied warranties of merchantability and fitness, in no event shall -- Rational be liable for any special, indirect or consequential damages or -- any damages whatsoever resulting from loss of use, data or profits, whether -- in an action of contract, negligence or other tortious action, arising out -- of or in connection with the use or performance of this software. ------------------------------------------------------------------------------ type Range_Type is private; ------------------------------------------------------------------------------ -- Range_Type - The data type to be stored within the map. This type must -- be constrained. ------------------------------------------------------------------------------ Hash_Size : S_Positive := 13; ------------------------------------------------------------------------------ -- Specifies the size of the hash table used. The value should always be -- a prime number and should be "large enough" to allow for "good" hash table -- performance. -- 13, 31, 59, 101, 211, 307, 401, 503, 751, 1009, 1511, 2003, 3001, 4001, -- 5003, 6007, 7001, 8009, 9001, 10007, 15013, 20011, 30011, 40009, 50021 ------------------------------------------------------------------------------ Exact_Case_Match : Boolean := True; ------------------------------------------------------------------------------ -- Specifies TRUE if "A" matches "A" but not "a". ------------------------------------------------------------------------------ package String_Map is type Map is private; type Iter is private; ------------------------------------------------------------------------------ -- Map - Variables of this type are String Maps; ie. maps from string values -- to values of some Range_Type. -- Iter - Variables of this type are used to iterate through all entries -- within a map. ------------------------------------------------------------------------------ None_Map : constant Map; None_Iter : constant Iter; ------------------------------------------------------------------------------ -- Uninitialized values. ------------------------------------------------------------------------------ Duplicate_Entry : exception; Missing_Entry : exception; ------------------------------------------------------------------------------ -- Duplicate_Entry - raised by Insert when duplicate keys conflict -- Missing_Entry - raised by Delete/Locate when a key is missing ------------------------------------------------------------------------------ procedure New_Map (M : out Map); ------------------------------------------------------------------------------ -- M - Receives a new Map. -- -- Called to create and initialize a new Map. The Map Is_Empty. ------------------------------------------------------------------------------ procedure Free_Map (M : in out Map); ------------------------------------------------------------------------------ -- M - Specifies the existing Map to deallocate. -- -- Called to destroy an existing Map. Map may have a None_Map value. All map -- entries are destroyed. The Range_Type values contained in the map are -- merely dropped and are not deallocated or manipulated in any way. ------------------------------------------------------------------------------ function Is_Empty (M : in Map) return Boolean; ------------------------------------------------------------------------------ -- M - Specifies the map -- -- Returns TRUE if the map is completely empty. ------------------------------------------------------------------------------ function Cardinality (M : in Map) return S_Natural; ------------------------------------------------------------------------------ -- M - Specifies the map -- -- Returns the number of entries in the map. ------------------------------------------------------------------------------ procedure Find (M : in Map; Key : in E_String; Rt : in out Range_Type; Success : out Boolean); ------------------------------------------------------------------------------ -- M - Specifies the map to use -- Key - Specifies the string value to use for the lookup -- Rt - Receives the Range_Type value from the map or is unchanged -- Success - Receives TRUE if the Key was found and FALSE if not -- -- Called to perform a lookup within the map. If the Key string is found -- within the map then the associated Range_Type value is returned and -- Success is set to TRUE. If the Key string is not found then Success is -- set to FALSE and the Rt parameter remains unchanged. (Beware of -- uninitialized locals being passed to Find; they will often be the cause -- of Constraint_Errors.) ------------------------------------------------------------------------------ function Locate (M : in Map; Key : in E_String) return Range_Type; ------------------------------------------------------------------------------ -- M - Specifies the map to use -- Key - Specifies the string value to use for the lookup -- -- Called to perform a lookup within the map. If the Key string is found -- within the map then the associated Range_Type value is returned. -- If the Key string is not found then Missing_Entry is raised. ------------------------------------------------------------------------------ procedure Insert (M : in Map; Key : in E_String; Rt : in Range_Type; Dups_Ok : in Boolean := False); ------------------------------------------------------------------------------ -- M - Specifies the map to use -- Key - Specifies the string value to use for the insertion -- Rt - Specifies the Range_Type value to be placed into the map -- Dups_Ok - Specifies TRUE if the new entry is allowed to replace an -- existing entry. -- -- Called to insert a new Range_Type value into the map. If Dups_Ok => FALSE -- then a preexisting map entry with the same Key value will cause -- Duplicate_Entry to be raised. ------------------------------------------------------------------------------ procedure Delete (M : in Map; Key : in E_String; Missing_Ok : in Boolean := False); ------------------------------------------------------------------------------ -- M - Specifies the map to use -- Key - Specifies the string value to use for the lookup -- Missing_Ok - Specifies TRUE if the entry need not exist -- -- Called to delete an existing Range_Type value from the map. Raises -- Missing_Entry if no matching Key entry is found unless Missing_Ok => TRUE. ------------------------------------------------------------------------------ procedure Remove (M : in Map; Key : in E_String; Rt : in out Range_Type; Success : out Boolean); ------------------------------------------------------------------------------ -- M - Specifies the map to use -- Key - Specifies the string value to use for the lookup -- Rt - Receives the Range_Type value from the map or is unchanged -- Success - Receives TRUE if the Key was found and FALSE if not -- -- Called to lookup and remove an entry within the map. If the Key string is -- found -- within the map then the associated Range_Type value is returned and -- Success is set to TRUE. If the Key string is not found then Success is -- set to FALSE and the Rt parameter remains unchanged. (Beware of -- uninitialized locals being passed to Find; they will often be the cause -- of Constraint_Errors.) ------------------------------------------------------------------------------ procedure Initialize (M : in Map; I : in out Iter); ------------------------------------------------------------------------------ -- M - Specifies the map -- I - Receives the new iteration value -- -- Called to initialize an iterator for a particular map. Iterators are -- used in this fashion: -- declare -- I : Iter; -- M : Map; -- Rt : Range_Type; -- begin -- Initilize (M, I); -- while not Done (I) loop -- Rt := Value (I); -- .... Code using the Rt value .... -- Next (I); -- end loop; -- end; -- Iterators are affected by changes to the map. Deletions can cause -- dereferencing of null pointers. Insertions are benign and new map entries -- may or may not appear as Values in the iteration depending upon the -- state of the Iter when the Insert is performed and also depending upon the -- value of the Key string. -- -- The iterator will advance through all entries within the map and the -- processing order of the entries is determined by the hash value of the -- Key strings and may or may not have any externally sensible ordering. ------------------------------------------------------------------------------ function Done (I : in Iter) return Boolean; ------------------------------------------------------------------------------ -- I - Specifies the iterator to check -- -- Returns TRUE when there are no more map entries to iterate through. ------------------------------------------------------------------------------ function Key (I : in Iter) return E_String; ------------------------------------------------------------------------------ -- I - Specifies the iterator to check -- -- Returns the key string value associated with the current value of the -- map iterator. Raises Missing_Entry if Done(I) = TRUE. ------------------------------------------------------------------------------ function Value (I : in Iter) return Range_Type; ------------------------------------------------------------------------------ -- I - Specifies the iterator to check -- -- Returns the Range_Type value associated with the current value of the -- map iterator. Raises Missing_Entry if Done(I) = TRUE. ------------------------------------------------------------------------------ procedure Next (I : in out Iter); ------------------------------------------------------------------------------ -- I - Specifies the iterator -- -- Advances the map iterator by one entry. Raises Missing_Entry if -- Done(I) = TRUE already. Done(I) = TRUE will be true when this routine -- returns if there are no more entries to be processed. ------------------------------------------------------------------------------ --\f private type Map_Rec; type Elem_Rec; type Element is access Elem_Rec; type Map is access Map_Rec; None_Map : constant Map := null; type Iter is record M : Map := null; Elem : Element := null; Index : S_Natural := 0; end record; None_Iter : constant Iter := (null, null, 0); end String_Map;