aboutsummaryrefslogtreecommitdiffstats
path: root/src/flists.ads
blob: 6adf43d863b1f00eb9353d95e5704ccdf516ffed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--  Fixed-length lists.
--  Copyright (C) 2017 Tristan Gingold
--
--  This program is free software: you can redistribute it and/or modify
--  it under the terms of the GNU General Public License as published by
--  the Free Software Foundation, either version 2 of the License, or
--  (at your option) any later version.
--
--  This program is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--  GNU General Public License for more details.
--
--  You should have received a copy of the GNU General Public License
--  along with this program.  If not, see <gnu.org/licenses>.
with Types; use Types;

generic
   type El_Type is range <>;
package Flists is
   type Flist_Type is new Int32;
   for Flist_Type'Size use 32;

   --  Non-existing flist.
   Null_Flist : constant Flist_Type := 0;

   --  Predefined special flist that could be used as a marker.
   Flist_Others : constant Flist_Type := 1;
   Flist_All : constant Flist_Type := 2;

   --  Create a new flist of length LEN.  All the elements are initialized to
   --  Null_Node.
   function Create_Flist (Len : Natural) return Flist_Type;

   --  Deallocate FLIST.  Set to Null_Flist.
   procedure Destroy_Flist (Flist : in out Flist_Type);

   --  First and last index of FLIST.  Could be used to iterate.
   Ffirst : constant Natural := 0;
   function Flast (Flist : Flist_Type) return Integer;

   --  Return the length of FLIST.
   function Length (Flist : Flist_Type) return Natural;

   --  Get the N-th element of FLIST.  First element has index 0.
   function Get_Nth_Element (Flist : Flist_Type; N : Natural) return El_Type;

   --  Set the N-th element of FLIST to V.
   procedure Set_Nth_Element (Flist : Flist_Type; N : Natural; V : El_Type);
end Flists;