DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T V

⟦97005ce4f⟧ TextFile

    Length: 7679 (0x1dff)
    Types: TextFile
    Names: »V«

Derivation

└─⟦85b835f43⟧ Bits:30000549 8mm tape, Rational 1000, Xlib rev 6.00
    └─ ⟦0c20f784e⟧ »DATA« 
        └─⟦1abbe589f⟧ 
            └─⟦591c5b094⟧ 
                └─⟦this⟧ 

TextFile

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.
------------------------------------------------------------------------------

    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_Heap is

    type Map  is private;
    type Iter is private;
------------------------------------------------------------------------------
-- Map - Variables of this type are String Heaps; ie. shared collections of
-- string values allocated upon the heap
-- 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 pointer values contained in the map are
-- are deallocated using Unchecked_Deallocation.
------------------------------------------------------------------------------

    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.
------------------------------------------------------------------------------

    function Share (M   : in Map;  
                    Key : in E_String) return E_String_Pointer;
------------------------------------------------------------------------------
--  M       - Specifies the map to use
--  Key     - Specifies the string value to use for the lookup
--
-- Returns a shared string containing the same characters as are found in Key.
------------------------------------------------------------------------------

    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;
--          Vl : E_String_Pointer;
--      begin
--          Initilize (M, I);
--          while not Done (I) loop
--              Vl := key (I);
--              .... Code using the Vl 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 Keys 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_Pointer;
------------------------------------------------------------------------------
--  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.
------------------------------------------------------------------------------

    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_Heap;