private with Ada.Containers.Ordered_Maps;
private with Locking_Objects;
generic
type Element_Type is private;
with function "="( left, right : Element_Type ) return Boolean is <>;
package Fully_Mutable_Lists is
type Cursor is private;
procedure Close( position : in out Cursor );
function Element( position : Cursor ) return Element_Type;
function Has_Element( position : Cursor ) return Boolean;
procedure Next( position : in out Cursor );
type List is tagged limited private;
procedure Append( this : access List; element : Element_Type );
procedure Find( this : access List; element : Element_Type; position : out Cursor );
function First( this : access List ) return Cursor;
function Is_Empty( this : access List ) return Boolean;
procedure Iterate( this : access List;
examine : access procedure( element : Element_Type ) );
procedure Iterate_With_Quit( this : access List;
examine : access procedure( element : Element_Type;
quit : in out Boolean ) );
function Length( this : access List ) return Natural;
procedure Prepend( this : access List; element : Element_Type );
procedure Remove( this : access List; position : in out Cursor );
CONTAINER_ERROR : exception;
private
use Locking_Objects;
type Node is limited
record
element : Element_Type;
end record;
type A_Node is access all Node;
procedure Delete( n : in out A_Node );
package Element_Maps is new Ada.Containers.Ordered_Maps( Integer, A_Node, "<", "=" );
type List is tagged limited
record
lock : A_Locking_Object := new Locking_Object;
least : Integer := 0;
greatest : Integer := 0;
contents : Element_Maps.Map;
end record;
procedure Find_Next( this : access List;
id : Integer;
nextId : out Integer;
nextNode : out A_Node );
pragma Postcondition( nextId = 0 xor nextNode /= null );
type Cursor is
record
list : access Fully_Mutable_Lists.List := null;
id : Integer := 0;
node : A_Node := null;
end record;
end Fully_Mutable_Lists;