DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

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

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦461b9e930⟧ Ada Source

    Length: 6144 (0x1800)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, generic, package Lists, seg_0043ed

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦this⟧ 

E3 Source Code



--| @SUMMARY This package implements a singly-linked list abstraction.
generic

    type Element is private;

package Lists is

    type List is private;

    function Create return List;
    --
    -- Returns an empty list.

    function Is_Empty (This_List : in List) return Boolean;
    --
    -- Returns True if the specified list contains no elements.

    function Elements_In (This_List : in List) return Natural;
    --
    -- Returns the number of elements in the specified list.

    generic

        with function Copy (Of_Element : in Element) return Element;

    function Copy (Of_List : in List) return List;
    --
    -- Returns a copy of the specified list using the supplied copy
    -- function to copy the individual elements. If the supplied copy
    -- function provides a true (non-aliased) copy of the elements, then
    -- the resulting copied list will be a true copy of the original
    -- list.
    --
    -- Very different from ":=".

    procedure Reset (This_List : in out List);
    --
    -- Resets the current element in the list to be the first element.
    --
    -- If the list is empty, has no effect (the list remains "Done").

    function Done (This_List : in List) return Boolean;
    --
    -- Returns True if the list has been advanced past the last element,
    -- or if the list is empty. Note that empty lists are always "Done",
    -- but "Done" lists are not necessarily empty.

    procedure Next (This_List : in out List);
    --
    -- Advances the current element in the list to the next element.
    --
    -- Raises "No_Next_Element" if "Done".

    function Current (This_List : in List) return Element;
    --
    -- Returns the current element in the list.
    --
    -- Raises "No_Current_Element" if "Done".

    type Positions is new Positive; -- Elements are numbered 1..N

    function Position (In_List : in List) return Positions;
    --   -- Returns the position corresponding to the current element in the list.
    --
    -- Raises "No_Current_Element" if already "Done".

    procedure Set (This_List : in out List; To_Position : in Positions);
    --
    -- Sets the current element in the list to the specified position.
    --
    -- Raises "Out_Of_Range" if the specified position is out of range.

    function Element_At (This_Position : in Positions; In_List : in List)
                        return Element;
    --
    -- Returns the element corresponding to the specified position.
    --
    -- Raises "Out_Of_Range" if the specified position is out of range.

    function Exists
                (In_This_List : List; This_Element : Element) return Boolean;
    -- determines if an element exists within a list

    procedure Add (To_List      : in out List;  
                   This_Element : in     Element);
    --
    -- Adds the specified element to the end of the list.
    --
    -- Does not alter iterator state. The iterator is still pointing to the
    -- same element as it was before the operation (the only exception to
    -- this is if the element just added is the only element in the list,
    -- in which case it becomes the first element, the last element, the
    -- current position, and the current element simultaneously).

    procedure Insert (To_List              : in out List;
                      This_Element         : in     Element;
                      Before_This_Position : in     Positions);
    -- inserts an element in the middle of the list

    procedure Modify (This_List : in out List; New_Element : in Element);
    --
    -- Replaces the current element in the list with the new element.
    -- Can be called during iteration without altering iterator's position.
    --
    -- Raises "No_Current_Element" if "Done".

    No_Current_Element : exception;
    No_Next_Element    : exception;

    Out_Of_Range : exception;

    -- Note: the "Add" operation propagates Storage_Error if it occurs.

private

    type Node;

    type Pointer is access Node;

    type Node is  
        record
            Contents : Element;  
            Next     : Pointer := null;  
        end record;

    type List is  
        record
            First    : Pointer := null;
            Last     : Pointer := null;
            Current  : Pointer := null;
            Position : Natural := 0;
            Count    : Natural := 0;  
        end record;

end Lists;  

E3 Meta Data

    nblk1=5
    nid=0
    hdr6=a
        [0x00] rec0=23 rec1=00 rec2=01 rec3=022
        [0x01] rec0=1e rec1=00 rec2=02 rec3=002
        [0x02] rec0=1a rec1=00 rec2=03 rec3=004
        [0x03] rec0=15 rec1=00 rec2=04 rec3=02e
        [0x04] rec0=1a rec1=00 rec2=05 rec3=000
    tail 0x21700169e815c6353777f 0x42a00088462061e03