3 -- Grant of Unlimited Rights
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
26 -- FOUNDATION DESCRIPTION:
27 -- This foundation defines a generic list abstraction. List elements can
28 -- be of any (nonlimited) type. Lists are implemented as singly linked
29 -- lists. Access to list elements is sequential. For each list, pointers
30 -- are maintained to the first and last elements in the list, as well as
31 -- the next element to be accessed.
34 -- 06 Dec 94 SAIC ACVC 2.0
38 generic -- List abstraction.
39 type Element_Type
is private; -- List elems can be of any nonlimited type.
42 type List_Type
is limited private;
44 -- Return true if current element is last in the list.
45 function End_Of_List
(L
: List_Type
) return Boolean;
47 -- Read current element value; do NOT advance "current" pointer.
48 procedure View_Element
(L
: in List_Type
; E
: out Element_Type
);
50 -- Read from current element and advance "current" pointer.
51 procedure Read_Element
(L
: in out List_Type
; E
: out Element_Type
);
53 -- Write to current element and advance "current" pointer.
54 procedure Write_Element
(L
: in out List_Type
; E
: in Element_Type
);
56 -- Add element to end of list.
57 procedure Add_Element
(L
: in out List_Type
; E
: in Element_Type
);
59 -- Set "current" pointer to first list element.
60 procedure Reset
(L
: in out List_Type
);
65 type Node_Pointer
is access Node_Type
;
67 type Node_Type
is record
72 type List_Type
is record
74 Current
: Node_Pointer
;
81 --==================================================================--
84 package body FC70B00
is
86 function End_Of_List
(L
: List_Type
) return Boolean is
88 return (L
.Current
= null);
92 procedure View_Element
(L
: in List_Type
; E
: out Element_Type
) is
94 -- ... Error-checking code omitted for brevity.
95 E
:= L
.Current
.Item
; -- Retrieve current element.
99 procedure Read_Element
(L
: in out List_Type
; E
: out Element_Type
) is
101 -- ... Error-checking code omitted for brevity.
102 E
:= L
.Current
.Item
; -- Retrieve current element.
103 L
.Current
:= L
.Current
.Next
; -- Advance "current" pointer.
107 procedure Write_Element
(L
: in out List_Type
; E
: in Element_Type
) is
109 -- ... Error-checking code omitted for brevity.
110 L
.Current
.Item
:= E
; -- Write to current element.
111 L
.Current
:= L
.Current
.Next
; -- Advance "current" pointer.
115 procedure Add_Element
(L
: in out List_Type
; E
: in Element_Type
) is
116 New_Node
: Node_Pointer
:= new Node_Type
'(E, null);
118 if L.First = null then -- No elements in list, so add new
119 L.First := New_Node; -- element at beginning of list.
121 L.Last.Next := New_Node; -- Add new element at end of list.
123 L.Last := New_Node; -- Set last-in-list pointer.
127 procedure Reset (L : in out List_Type) is
129 L.Current := L.First; -- Set "current" pointer to first
130 end Reset; -- list element.