agpl_1.0.0_b5da3320/src/agpl-containers-algorithms.ads

 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
with Ada.Containers;

package Agpl.Containers.Algorithms is

   --  Extra algorithms for containers
   pragma Preelaborate;

   Log_Section : constant String := "agpl.containers.algorithms";

   generic
      type Container is private;
      type Element_Type (<>) is private;
      type Cursor is private;
--      with function "="     (L, R : Element_Type) return Boolean is <>;
      with function Element (Position : Cursor) return Element_Type is <>;
   package Basic is

      generic
         with procedure Append
           (Cont      : in out Container;
            New_Item  :        Element_Type;
            Count     :        Ada.Containers.Count_Type := 1) is <>;
         with procedure Iterate
           (Cont    : Container;
            Process : not null access procedure (Position : Cursor)) is <>;
      procedure Append (Dst : in out Container;
                        Src :        Container);

      generic
         with procedure Prepend
           (Cont      : in out Container;
            New_Item  :        Element_Type;
            Count     :        Ada.Containers.Count_Type := 1) is <>;
         with procedure Iterate
           (Cont    : Container;
            Process : not null access procedure (Position : Cursor)) is <>;
      function Invert (Cont : Container) return Container;
      --  Reverse is a reserved keyword

      generic
         with function Has_Element (Position : Cursor) return Boolean is <>;
         with function First       (Cont : Container) return Cursor is <>;
         with function Last        (Cont : container) return Cursor is <>;
         with function Next        (Position : Cursor) return Cursor is <>;
         with function Previous    (Position : Cursor) return Cursor is <>;
         with procedure Append
           (Cont      : in out Container;
            New_Item  :        Element_Type;
            Count     :        Ada.Containers.Count_Type := 1) is <>;
      package Fields is

         --  Getting parts of a container

         function Slice (Cont : Container;
                         Ini,
                         Fin  : Element_Type;
                         Pos  : Positive := 1) return Container;
         --  If Ini or Fin don't appear in the matching position, empty result.

         function Head (Cont : Container;
                        Sep  : Element_Type;
                        Pos  : Positive := 1) return Container;
         --  The start of a Container starting at Separator, counting Pos from start.
         --  Separator obviously not included.

         function Tail (Cont : Container;
                        Sep  : Element_Type;
                        Pos  : Positive := 1) return Container;
         --  The remainder of a Container starting at Separator, counting Pos from end.
         --  Separator obviously not included.

      end Fields;

      generic
         type Other_Container is private;
         with procedure Append
           (Cont      : in out Other_Container;
            New_Item  :        Element_Type;
            Count     :        Ada.Containers.Count_Type := 1) is <>;
         with procedure Iterate
           (Cont    : Container;
            Process : not null access procedure (Position : Cursor)) is <>;
      package Conversions is

         function Convert (This : Container) return Other_Container;

      end Conversions;

   end Basic;

end Agpl.Containers.Algorithms;