2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / ada / acats / support / fc70b00.a
blob46b106e0b25a0e3fad98ea1719cad3bdb7337544
1 -- FC70B00.A
2 --
3 -- Grant of Unlimited Rights
4 --
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
14 -- to do so.
16 -- DISCLAIMER
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.
24 --*
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.
33 -- CHANGE HISTORY:
34 -- 06 Dec 94 SAIC ACVC 2.0
36 --!
38 generic -- List abstraction.
39 type Element_Type is private; -- List elems can be of any nonlimited type.
40 package FC70B00 is
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);
62 private
64 type Node_Type;
65 type Node_Pointer is access Node_Type;
67 type Node_Type is record
68 Item : Element_Type;
69 Next : Node_Pointer;
70 end record;
72 type List_Type is record
73 First : Node_Pointer;
74 Current : Node_Pointer;
75 Last : Node_Pointer;
76 end record;
78 end FC70B00;
81 --==================================================================--
84 package body FC70B00 is
86 function End_Of_List (L : List_Type) return Boolean is
87 begin
88 return (L.Current = null);
89 end End_Of_List;
92 procedure View_Element (L : in List_Type; E : out Element_Type) is
93 begin
94 -- ... Error-checking code omitted for brevity.
95 E := L.Current.Item; -- Retrieve current element.
96 end View_Element;
99 procedure Read_Element (L : in out List_Type; E : out Element_Type) is
100 begin
101 -- ... Error-checking code omitted for brevity.
102 E := L.Current.Item; -- Retrieve current element.
103 L.Current := L.Current.Next; -- Advance "current" pointer.
104 end Read_Element;
107 procedure Write_Element (L : in out List_Type; E : in Element_Type) is
108 begin
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.
112 end Write_Element;
115 procedure Add_Element (L : in out List_Type; E : in Element_Type) is
116 New_Node : Node_Pointer := new Node_Type'(E, null);
117 begin
118 if L.First = null then -- No elements in list, so add new
119 L.First := New_Node; -- element at beginning of list.
120 else
121 L.Last.Next := New_Node; -- Add new element at end of list.
122 end if;
123 L.Last := New_Node; -- Set last-in-list pointer.
124 end Add_Element;
127 procedure Reset (L : in out List_Type) is
128 begin
129 L.Current := L.First; -- Set "current" pointer to first
130 end Reset; -- list element.
133 end FC70B00;