source: trunk/ada-2012/src/semantic/gela-peristent_lists.ads@ 552

Last change on this file since 552 was 426, checked in by Maxim Reznik, 7 years ago

Minor refactoring

Rename Count_Type to List in Gela.Peristent_Lists. Hide Index_Type

  • Property svn:keywords set to Author Date Revision
File size: 1.5 KB
Line 
1with Ada.Containers.Vectors;
2
3generic
4 type Element_Type is private;
5
6package Gela.Peristent_Lists is
7 pragma Preelaborate;
8
9 type Container is tagged private;
10 -- Store actual values of Element_Type
11
12 type List is private;
13 -- Represent persistent list
14
15 Empty : constant List; -- Represent empty persistent list
16
17 procedure Prepend
18 (Self : in out Container;
19 Value : Element_Type;
20 Input : List := Empty;
21 Output : out List);
22
23 function Head
24 (Self : Container;
25 Index : List) return Element_Type;
26
27 function Tail
28 (Self : Container;
29 Index : List) return List;
30
31 procedure Delete
32 (Self : in out Container;
33 Input : List;
34 Value : Element_Type;
35 Output : out List);
36
37 procedure For_Each
38 (Self : Container;
39 Input : List;
40 Action : access procedure (Value : Element_Type));
41
42private
43
44 type List is new Natural;
45 -- Represent persistent list (empty for 0 or not otherwise)
46
47 Empty : constant List := 0;
48
49 package Element_Vectors is new
50 Ada.Containers.Vectors (Positive, Element_Type);
51
52 type Link is record
53 Value : Positive;
54 Next : List;
55 end record;
56
57 subtype Index_Type is List range 1 .. List'Last;
58 -- Represent non-empty persistent list
59
60 package Link_Vectors is new
61 Ada.Containers.Vectors (Index_Type, Link);
62
63 type Container is tagged record
64 Elements : Element_Vectors.Vector;
65 Links : Link_Vectors.Vector;
66 end record;
67
68end Gela.Peristent_Lists;
Note: See TracBrowser for help on using the repository browser.