agpl_1.0.0_b5da3320/src/agpl-containers-protected_indefinite_doubly_linked_lists.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
with Ada.Containers;
with Ada.Containers.Indefinite_Doubly_Linked_Lists;

generic
   type Element_Type (<>) is private;
   with function "=" (Left, Right : Element_Type) return Boolean is <>;
package Agpl.Containers.Protected_Indefinite_Doubly_Linked_Lists is

   pragma Preelaborate;

   subtype Count_Type is Ada.Containers.Count_Type;

   --  This is not to be used!! Should be hidden :'(
   package Container is new
     Ada.Containers.Indefinite_Doubly_Linked_Lists (Element_Type, "=");

   protected type Protected_List is

      procedure Clear;

      procedure Append
        (New_Item  : Element_Type;
         Count     : Count_Type := 1);

      procedure Delete_First (Count : Count_Type := 1);

      function First_Element return Element_Type;
      --  Exception if empty

      entry First_Element_Blocking (Item : out Element_Type);
      --  Block until some element available
      --  Doesn't delete it.

      entry First_Element_Blocking_And_Delete (Item : out Element_Type);

      function Is_Empty return Boolean;

      function Length return Count_Type;

   private
      Internal : Container.List;
   end Protected_List;

end Agpl.Containers.Protected_Indefinite_Doubly_Linked_Lists;