1--  Fixed-length lists.
2--  Copyright (C) 2017 Tristan Gingold
3--
4--  This program is free software: you can redistribute it and/or modify
5--  it under the terms of the GNU General Public License as published by
6--  the Free Software Foundation, either version 2 of the License, or
7--  (at your option) any later version.
8--
9--  This program is distributed in the hope that it will be useful,
10--  but WITHOUT ANY WARRANTY; without even the implied warranty of
11--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12--  GNU General Public License for more details.
13--
14--  You should have received a copy of the GNU General Public License
15--  along with this program.  If not, see <gnu.org/licenses>.
16with Types; use Types;
17
18generic
19   type El_Type is range <>;
20package Flists is
21   type Flist_Type is new Int32;
22   for Flist_Type'Size use 32;
23
24   --  Non-existing flist.
25   Null_Flist : constant Flist_Type := 0;
26
27   --  Predefined special flist that could be used as a marker.
28   Flist_Others : constant Flist_Type := 1;
29   Flist_All : constant Flist_Type := 2;
30
31   --  Create a new flist of length LEN.  All the elements are initialized to
32   --  Null_Node.
33   function Create_Flist (Len : Natural) return Flist_Type;
34
35   --  Deallocate FLIST.  Set to Null_Flist.
36   procedure Destroy_Flist (Flist : in out Flist_Type);
37
38   --  First and last index of FLIST.  Could be used to iterate.
39   Ffirst : constant Natural := 0;
40   function Flast (Flist : Flist_Type) return Integer;
41
42   --  Return the length of FLIST.
43   function Length (Flist : Flist_Type) return Natural;
44
45   --  Get the N-th element of FLIST.  First element has index 0.
46   function Get_Nth_Element (Flist : Flist_Type; N : Natural) return El_Type;
47
48   --  Set the N-th element of FLIST to V.
49   procedure Set_Nth_Element (Flist : Flist_Type; N : Natural; V : El_Type);
50end Flists;
51