1--  Copyright 2001-2014 Simon Wright <simon@pushface.org>
2
3--  This package is free software; you can redistribute it and/or
4--  modify it under terms of the GNU General Public License as
5--  published by the Free Software Foundation; either version 2, or
6--  (at your option) any later version. This package is distributed in
7--  the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8--  even the implied warranty of MERCHANTABILITY or FITNESS FOR A
9--  PARTICULAR PURPOSE. See the GNU General Public License for more
10--  details. You should have received a copy of the GNU General Public
11--  License distributed with this package; see file COPYING.  If not,
12--  write to the Free Software Foundation, 59 Temple Place - Suite
13--  330, Boston, MA 02111-1307, USA.
14
15--  As a special exception, if other files instantiate generics from
16--  this unit, or you link this unit with other files to produce an
17--  executable, this unit does not by itself cause the resulting
18--  executable to be covered by the GNU General Public License.  This
19--  exception does not however invalidate any other reasons why the
20--  executable file might be covered by the GNU Public License.
21
22package body BC.Simple_Collections is
23
24   function Null_Container return Collection is
25      Empty_Container : Collection;
26      pragma Warnings (Off, Empty_Container);
27   begin
28      return Empty_Container;
29   end Null_Container;
30
31   function Null_Collection return Collection is
32   begin
33      return Null_Container;
34   end Null_Collection;
35
36   function "=" (Left, Right : in Collection) return Boolean is
37   begin
38      return Collections."=" (Collections.Collection (Left),
39                              Collections.Collection (Right));
40   end "=";
41
42   procedure Clear (C : in out Collection) is
43   begin
44      Collections.Clear (Collections.Collection (C));
45   end Clear;
46
47   procedure Insert (C : in out Collection; Elem : Item) is
48   begin
49      Collections.Insert (Collections.Collection (C), Elem);
50   end Insert;
51
52   procedure Insert (C : in out Collection;
53                     Elem : Item; Before : Positive) is
54   begin
55      Collections.Insert (Collections.Collection (C), Elem, Before);
56   end Insert;
57
58   procedure Append (C : in out Collection; Elem : Item) is
59   begin
60      Collections.Append (Collections.Collection (C), Elem);
61   end Append;
62
63   procedure Append (C : in out Collection;
64                     Elem : Item;
65                     After : Positive) is
66   begin
67      Collections.Append (Collections.Collection (C), Elem, After);
68   end Append;
69
70   procedure Remove (C : in out Collection;
71                     At_Index : Positive) is
72   begin
73      Collections.Remove (Collections.Collection (C), At_Index);
74   end Remove;
75
76   procedure Replace (C : in out Collection;
77                      At_Index : Positive; Elem : Item) is
78   begin
79      Collections.Replace (Collections.Collection (C), At_Index, Elem);
80   end Replace;
81
82   function Length (C : Collection) return Natural is
83   begin
84      return Collections.Length (Collections.Collection (C));
85   end Length;
86
87   function Is_Empty (C : Collection) return Boolean is
88   begin
89      return Collections.Is_Empty (Collections.Collection (C));
90   end Is_Empty;
91
92   function First (C : Collection) return Item is
93   begin
94      return Collections.First (Collections.Collection (C));
95   end First;
96
97   function Last (C : Collection) return Item is
98   begin
99      return Collections.Last (Collections.Collection (C));
100   end Last;
101
102   function Item_At (C : Collection;
103                     At_Index : Positive) return Item is
104   begin
105      return Collections.Item_At (Collections.Collection (C), At_Index);
106   end Item_At;
107
108   function Location (C : Collection;
109                      Elem : Item) return Natural is
110   begin
111      return Collections.Location (Collections.Collection (C), Elem);
112   end Location;
113
114   function New_Iterator
115     (For_The_Collection : Collection) return Iterator'Class is
116   begin
117      return Collections.New_Iterator
118        (Collections.Collection (For_The_Collection));
119   end New_Iterator;
120
121   procedure Reset (It : in out Iterator) is
122   begin
123      Abstract_Containers.Reset (It);
124   end Reset;
125
126   procedure Next (It : in out Iterator) is
127   begin
128      Abstract_Containers.Next (It);
129   end Next;
130
131   function Is_Done (It : Iterator) return Boolean is
132   begin
133      return Abstract_Containers.Is_Done (It);
134   end Is_Done;
135
136   function Current_Item (It : Iterator) return Item is
137   begin
138      return Abstract_Containers.Current_Item (It);
139   end Current_Item;
140
141end BC.Simple_Collections;
142