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 - metrics - download
Index: B T

⟦93780ca56⟧ TextFile

    Length: 3201 (0xc81)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

separate (Halstead_List)
procedure Put (This_Item : in Item; Into : in out List) is
    --==============================================================
    -- Put an item into a list. If the given item is a new item,  ==
    -- it will be put into the list. If the given item already    ==
    -- exists, the frequency of the item will be incremented by   ==
    -- one. Items will be stored in ASCENDING order.              ==
    --==============================================================

    Trailing_Node : List;
    Current_Node : List;
    New_Node : List;
    Item_Exists : Boolean := False;
    Found_Insertion_Point : Boolean := False;

begin
    -- Put

    -- check whether the list is empty or not
    if Into = null then

        -- get a new node
        Get (New_Node => Into);

        -- put item in the new node
        Into.all := (Location_Of_Item => new Item'(This_Item),
                     Frequency => 1,
                     Next => null);

    elsif This_Item < Into.Location_Of_Item.all then

        -- insert This_Item in front

        -- get a new node
        Get (New_Node => New_Node);

        -- put item in the new node
        New_Node.all := (Location_Of_Item => new Item'(This_Item),
                         Frequency => 1,
                         Next => Into);

        -- change the list pointer
        Into := New_Node;

    else
        -- insert in the middle of the last of the list

        Current_Node := Into;

        -- find out whether This_Item already exists or not
        Find_Insertion_Point:
            loop

                if Current_Node.Location_Of_Item.all < This_Item then

                    -- save Current_Node in Trailing_Node
                    Trailing_Node := Current_Node;

                    -- advance Current_Node
                    Current_Node := Current_Node.Next;

                elsif Is_Equal (Left => Current_Node.Location_Of_Item.all,
                                Right => This_Item) then

                    -- item already exists, so simply increment the frequency
                    Current_Node.Frequency := Current_Node.Frequency + 1;

                    -- set Item_Exists to true
                    Item_Exists := True;

                else
                    -- Current_Node.Location_Of_Item.all > This_Item

                    -- found the insertion point
                    Found_Insertion_Point := True;

                end if;

                exit Find_Insertion_Point when
                   Item_Exists or Found_Insertion_Point or Current_Node = null;

            end loop Find_Insertion_Point;

        -- find out whether insertion is needed or not
        if Item_Exists then

            -- item was found
            null;

        else
            -- insert to the right of the trailing pointer node

            -- get a new node
            Get (New_Node => New_Node);

            -- put item in the new node
            New_Node.all := (Location_Of_Item => new Item'(This_Item),
                             Frequency => 1,
                             Next => Current_Node);

            Trailing_Node.Next := New_Node;

        end if;

    end if;

end Put;