end if;
while RI.Node /= null loop
+ pragma Assert (RI.Node.Next = null
+ or else not (RI.Node.Next.Element <
+ RI.Node.Element));
+
if LI.Node = null then
Splice (Target, No_Element, Source);
return;
end if;
+ pragma Assert (LI.Node.Next = null
+ or else not (LI.Node.Next.Element <
+ LI.Node.Element));
+
if RI.Node.Element < LI.Node.Element then
declare
RJ : Cursor := RI;
end Splice;
procedure Splice
- (Target : in out List;
- Before : Cursor;
- Position : Cursor)
+ (Container : in out List;
+ Before : Cursor;
+ Position : in out Cursor)
is
begin
if Before.Container /= null then
- if Before.Container /= Target'Unchecked_Access then
+ if Before.Container /= Container'Unchecked_Access then
raise Program_Error;
end if;
raise Constraint_Error;
end if;
- if Position.Container /= Target'Unrestricted_Access then
+ if Position.Container /= Container'Unrestricted_Access then
raise Program_Error;
end if;
return;
end if;
- pragma Assert (Target.Length >= 2);
+ pragma Assert (Container.Length >= 2);
- if Target.Busy > 0 then
+ if Container.Busy > 0 then
raise Program_Error;
end if;
if Before.Node = null then
- pragma Assert (Position.Node /= Target.Last);
+ pragma Assert (Position.Node /= Container.Last);
- if Position.Node = Target.First then
- Target.First := Position.Node.Next;
- Target.First.Prev := null;
+ if Position.Node = Container.First then
+ Container.First := Position.Node.Next;
+ Container.First.Prev := null;
else
Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev;
end if;
- Target.Last.Next := Position.Node;
- Position.Node.Prev := Target.Last;
+ Container.Last.Next := Position.Node;
+ Position.Node.Prev := Container.Last;
- Target.Last := Position.Node;
- Target.Last.Next := null;
+ Container.Last := Position.Node;
+ Container.Last.Next := null;
return;
end if;
- if Before.Node = Target.First then
- pragma Assert (Position.Node /= Target.First);
+ if Before.Node = Container.First then
+ pragma Assert (Position.Node /= Container.First);
- if Position.Node = Target.Last then
- Target.Last := Position.Node.Prev;
- Target.Last.Next := null;
+ if Position.Node = Container.Last then
+ Container.Last := Position.Node.Prev;
+ Container.Last.Next := null;
else
Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev;
end if;
- Target.First.Prev := Position.Node;
- Position.Node.Next := Target.First;
+ Container.First.Prev := Position.Node;
+ Position.Node.Next := Container.First;
- Target.First := Position.Node;
- Target.First.Prev := null;
+ Container.First := Position.Node;
+ Container.First.Prev := null;
return;
end if;
- if Position.Node = Target.First then
- Target.First := Position.Node.Next;
- Target.First.Prev := null;
+ if Position.Node = Container.First then
+ Container.First := Position.Node.Next;
+ Container.First.Prev := null;
- elsif Position.Node = Target.Last then
- Target.Last := Position.Node.Prev;
- Target.Last.Next := null;
+ elsif Position.Node = Container.Last then
+ Container.Last := Position.Node.Prev;
+ Container.Last.Next := null;
else
Position.Node.Prev.Next := Position.Node.Next;
Before.Node.Prev := Position.Node;
Position.Node.Next := Before.Node;
- pragma Assert (Target.First.Prev = null);
- pragma Assert (Target.Last.Next = null);
+ pragma Assert (Container.First.Prev = null);
+ pragma Assert (Container.Last.Next = null);
end Splice;
procedure Splice
declare
I_Next : constant Cursor := Next (I);
+ J_Copy : Cursor := J;
begin
if I_Next = J then
- Splice (Container, Before => I, Position => J);
+ Splice (Container, Before => I, Position => J_Copy);
else
declare
J_Next : constant Cursor := Next (J);
+ I_Copy : Cursor := I;
begin
if J_Next = I then
- Splice (Container, Before => J, Position => I);
+ Splice (Container, Before => J, Position => I_Copy);
else
pragma Assert (Container.Length >= 3);
- Splice (Container, Before => I_Next, Position => J);
- Splice (Container, Before => J_Next, Position => I);
+ Splice (Container, Before => I_Next, Position => J_Copy);
+ Splice (Container, Before => J_Next, Position => I_Copy);
end if;
end;
end if;
Position : in out Cursor);
procedure Splice
- (Target : in out List;
- Before : Cursor;
- Position : Cursor);
+ (Container : in out List;
+ Before : Cursor;
+ Position : in out Cursor);
function First (Container : List) return Cursor;
LI := First (Target);
RI := First (Source);
while RI.Node /= null loop
+ pragma Assert (RI.Node.Next = null
+ or else not (RI.Node.Next.Element.all <
+ RI.Node.Element.all));
+
if LI.Node = null then
Splice (Target, No_Element, Source);
return;
end if;
+ pragma Assert (LI.Node.Next = null
+ or else not (LI.Node.Next.Element.all <
+ LI.Node.Element.all));
+
if RI.Node.Element.all < LI.Node.Element.all then
declare
RJ : Cursor := RI;
end Splice;
procedure Splice
- (Target : in out List;
- Before : Cursor;
- Position : Cursor)
+ (Container : in out List;
+ Before : Cursor;
+ Position : in out Cursor)
is
begin
if Before.Container /= null then
- if Before.Container /= Target'Unchecked_Access then
+ if Before.Container /= Container'Unchecked_Access then
raise Program_Error;
end if;
raise Program_Error;
end if;
- if Position.Container /= Target'Unrestricted_Access then
+ if Position.Container /= Container'Unrestricted_Access then
raise Program_Error;
end if;
return;
end if;
- pragma Assert (Target.Length >= 2);
+ pragma Assert (Container.Length >= 2);
- if Target.Busy > 0 then
+ if Container.Busy > 0 then
raise Program_Error;
end if;
if Before.Node = null then
- pragma Assert (Position.Node /= Target.Last);
+ pragma Assert (Position.Node /= Container.Last);
- if Position.Node = Target.First then
- Target.First := Position.Node.Next;
- Target.First.Prev := null;
+ if Position.Node = Container.First then
+ Container.First := Position.Node.Next;
+ Container.First.Prev := null;
else
Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev;
end if;
- Target.Last.Next := Position.Node;
- Position.Node.Prev := Target.Last;
+ Container.Last.Next := Position.Node;
+ Position.Node.Prev := Container.Last;
- Target.Last := Position.Node;
- Target.Last.Next := null;
+ Container.Last := Position.Node;
+ Container.Last.Next := null;
return;
end if;
- if Before.Node = Target.First then
- pragma Assert (Position.Node /= Target.First);
+ if Before.Node = Container.First then
+ pragma Assert (Position.Node /= Container.First);
- if Position.Node = Target.Last then
- Target.Last := Position.Node.Prev;
- Target.Last.Next := null;
+ if Position.Node = Container.Last then
+ Container.Last := Position.Node.Prev;
+ Container.Last.Next := null;
else
Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev;
end if;
- Target.First.Prev := Position.Node;
- Position.Node.Next := Target.First;
+ Container.First.Prev := Position.Node;
+ Position.Node.Next := Container.First;
- Target.First := Position.Node;
- Target.First.Prev := null;
+ Container.First := Position.Node;
+ Container.First.Prev := null;
return;
end if;
- if Position.Node = Target.First then
- Target.First := Position.Node.Next;
- Target.First.Prev := null;
+ if Position.Node = Container.First then
+ Container.First := Position.Node.Next;
+ Container.First.Prev := null;
- elsif Position.Node = Target.Last then
- Target.Last := Position.Node.Prev;
- Target.Last.Next := null;
+ elsif Position.Node = Container.Last then
+ Container.Last := Position.Node.Prev;
+ Container.Last.Next := null;
else
Position.Node.Prev.Next := Position.Node.Next;
Before.Node.Prev := Position.Node;
Position.Node.Next := Before.Node;
- pragma Assert (Target.First.Prev = null);
- pragma Assert (Target.Last.Next = null);
+ pragma Assert (Container.First.Prev = null);
+ pragma Assert (Container.Last.Next = null);
end Splice;
procedure Splice
declare
I_Next : constant Cursor := Next (I);
+ J_Copy : Cursor := J;
begin
if I_Next = J then
- Splice (Container, Before => I, Position => J);
+ Splice (Container, Before => I, Position => J_Copy);
else
declare
J_Next : constant Cursor := Next (J);
+ I_Copy : Cursor := I;
+
begin
if J_Next = I then
- Splice (Container, Before => J, Position => I);
+ Splice (Container, Before => J, Position => I_Copy);
else
pragma Assert (Container.Length >= 3);
- Splice (Container, Before => I_Next, Position => J);
- Splice (Container, Before => J_Next, Position => I);
+ Splice (Container, Before => I_Next, Position => J_Copy);
+ Splice (Container, Before => J_Next, Position => I_Copy);
end if;
end;
end if;
Position : in out Cursor);
procedure Splice
- (Target : in out List;
- Before : Cursor;
- Position : Cursor);
+ (Container : in out List;
+ Before : Cursor;
+ Position : in out Cursor);
function First (Container : List) return Cursor;
raise Constraint_Error;
end if;
+ if Position.Node.Element = null then
+ raise Program_Error;
+ end if;
+
return Position.Node.Element.all;
end Element;
raise Constraint_Error;
end if;
+ if Left.Node.Key = null
+ or else Right.Node.Key = null
+ then
+ raise Program_Error;
+ end if;
+
return Equivalent_Keys (Left.Node.Key.all, Right.Node.Key.all);
end Equivalent_Keys;
raise Constraint_Error;
end if;
+ if Left.Node.Key = null then
+ raise Program_Error;
+ end if;
+
return Equivalent_Keys (Left.Node.Key.all, Right);
end Equivalent_Keys;
raise Constraint_Error;
end if;
+ if Right.Node.Key = null then
+ raise Program_Error;
+ end if;
+
return Equivalent_Keys (Left, Right.Node.Key.all);
end Equivalent_Keys;
raise Constraint_Error;
end if;
+ if Position.Node.Key = null then
+ raise Program_Error;
+ end if;
+
return Position.Node.Key.all;
end Key;
return No_Element;
end if;
+ if Position.Node.Key = null
+ or else Position.Node.Element = null
+ then
+ raise Program_Error;
+ end if;
+
declare
HT : Hash_Table_Type renames Position.Container.HT;
Node : constant Node_Access := HT_Ops.Next (HT, Position.Node);
raise Constraint_Error;
end if;
+ if Position.Node.Key = null
+ or else Position.Node.Element = null
+ then
+ raise Program_Error;
+ end if;
+
declare
M : Map renames Position.Container.all;
HT : Hash_Table_Type renames M.HT'Unrestricted_Access.all;
raise Constraint_Error;
end if;
+ if Position.Node.Key = null
+ or else Position.Node.Element = null
+ then
+ raise Program_Error;
+ end if;
+
if Position.Container /= Container'Unrestricted_Access then
raise Program_Error;
end if;
raise Constraint_Error;
end if;
+ if Position.Node.Key = null
+ or else Position.Node.Element = null
+ then
+ raise Program_Error;
+ end if;
+
if Position.Container /= Container'Unrestricted_Access then
raise Program_Error;
end if;
function "<" (Left, Right : Cursor) return Boolean is
begin
- if Left.Node = null
- or else Right.Node = null
- then
- raise Constraint_Error;
+ if Left.Node = null then
+ raise Constraint_Error with "Left cursor of ""<"" equals No_Element";
end if;
- if Left.Node.Key = null
- or else Right.Node.Key = null
- then
- raise Program_Error;
+ if Right.Node = null then
+ raise Constraint_Error with "Right cursor of ""<"" equals No_Element";
+ end if;
+
+ if Left.Node.Key = null then
+ raise Program_Error with "Left cursor in ""<"" is bad";
+ end if;
+
+ if Right.Node.Key = null then
+ raise Program_Error with "Right cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
- "bad Left cursor in ""<""");
+ "Left cursor in ""<"" is bad");
pragma Assert (Vet (Right.Container.Tree, Right.Node),
- "bad Right cursor in ""<""");
+ "Right cursor in ""<"" is bad");
return Left.Node.Key.all < Right.Node.Key.all;
end "<";
function "<" (Left : Cursor; Right : Key_Type) return Boolean is
begin
if Left.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "Left cursor of ""<"" equals No_Element";
end if;
if Left.Node.Key = null then
- raise Program_Error;
+ raise Program_Error with "Left cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
- "bad Left cursor in ""<""");
+ "Left cursor in ""<"" is bad");
return Left.Node.Key.all < Right;
end "<";
function "<" (Left : Key_Type; Right : Cursor) return Boolean is
begin
if Right.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "Right cursor of ""<"" equals No_Element";
end if;
if Right.Node.Key = null then
- raise Program_Error;
+ raise Program_Error with "Right cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Right.Container.Tree, Right.Node),
- "bad Right cursor in ""<""");
+ "Right cursor in ""<"" is bad");
return Left < Right.Node.Key.all;
end "<";
function ">" (Left, Right : Cursor) return Boolean is
begin
- if Left.Node = null
- or else Right.Node = null
- then
- raise Constraint_Error;
+ if Left.Node = null then
+ raise Constraint_Error with "Left cursor of "">"" equals No_Element";
end if;
- if Left.Node.Key = null
- or else Right.Node.Key = null
- then
- raise Program_Error;
+ if Right.Node = null then
+ raise Constraint_Error with "Right cursor of "">"" equals No_Element";
+ end if;
+
+ if Left.Node.Key = null then
+ raise Program_Error with "Left cursor in ""<"" is bad";
+ end if;
+
+ if Right.Node.Key = null then
+ raise Program_Error with "Right cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
- "bad Left cursor in "">""");
+ "Left cursor in "">"" is bad");
pragma Assert (Vet (Right.Container.Tree, Right.Node),
- "bad Right cursor in "">""");
+ "Right cursor in "">"" is bad");
return Right.Node.Key.all < Left.Node.Key.all;
end ">";
function ">" (Left : Cursor; Right : Key_Type) return Boolean is
begin
if Left.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "Left cursor of "">"" equals No_Element";
end if;
if Left.Node.Key = null then
- raise Program_Error;
+ raise Program_Error with "Left cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
- "bad Left cursor in "">""");
+ "Left cursor in "">"" is bad");
return Right < Left.Node.Key.all;
end ">";
function ">" (Left : Key_Type; Right : Cursor) return Boolean is
begin
if Right.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "Right cursor of "">"" equals No_Element";
end if;
if Right.Node.Key = null then
- raise Program_Error;
+ raise Program_Error with "Right cursor in ""<"" is bad";
end if;
pragma Assert (Vet (Right.Container.Tree, Right.Node),
- "bad Right cursor in "">""");
+ "Right cursor in "">"" is bad");
return Right.Node.Key.all < Left;
end ">";
is
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of Delete equals No_Element";
end if;
if Position.Node.Key = null
or else Position.Node.Element = null
then
- raise Program_Error;
+ raise Program_Error with "Position cursor of Delete is bad";
end if;
if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error;
+ raise Program_Error with
+ "Position cursor of Delete designates wrong map";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
- "bad cursor in Delete");
+ "Position cursor of Delete is bad");
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, Position.Node);
Free (Position.Node);
begin
if X = null then
- raise Constraint_Error;
+ raise Constraint_Error with "key not in map";
end if;
Delete_Node_Sans_Free (Container.Tree, X);
function Element (Position : Cursor) return Element_Type is
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of function Element equals No_Element";
end if;
if Position.Node.Element = null then
- raise Program_Error;
+ raise Program_Error with
+ "Position cursor of function Element is bad";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
- "bad cursor in Element");
+ "Position cursor of function Element is bad");
return Position.Node.Element.all;
end Element;
begin
if Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "key not in map";
end if;
return Node.Element.all;
begin
if T.First = null then
- raise Constraint_Error;
+ raise Constraint_Error with "map is empty";
end if;
return T.First.Element.all;
begin
if T.First = null then
- raise Constraint_Error;
+ raise Constraint_Error with "map is empty";
end if;
return T.First.Key.all;
if not Inserted then
if Container.Tree.Lock > 0 then
- raise Program_Error;
+ raise Program_Error with
+ "attempt to tamper with cursors (map is locked)";
end if;
K := Position.Node.Key;
Insert (Container, Key, New_Item, Position, Inserted);
if not Inserted then
- raise Constraint_Error;
+ raise Constraint_Error with "key already in map";
end if;
end Insert;
function Key (Position : Cursor) return Key_Type is
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of function Key equals No_Element";
end if;
if Position.Node.Key = null then
- raise Program_Error;
+ raise Program_Error with
+ "Position cursor of function Key is bad";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
- "bad cursor in Key");
+ "Position cursor of function Key is bad");
return Position.Node.Key.all;
end Key;
begin
if T.Last = null then
- raise Constraint_Error;
+ raise Constraint_Error with "map is empty";
end if;
return T.Last.Element.all;
begin
if T.Last = null then
- raise Constraint_Error;
+ raise Constraint_Error with "map is empty";
end if;
return T.Last.Key.all;
pragma Assert (Position.Node.Key /= null);
pragma Assert (Position.Node.Element /= null);
pragma Assert (Vet (Position.Container.Tree, Position.Node),
- "bad cursor in Next");
+ "Position cursor of Next is bad");
declare
Node : constant Node_Access :=
pragma Assert (Position.Node.Key /= null);
pragma Assert (Position.Node.Element /= null);
pragma Assert (Vet (Position.Container.Tree, Position.Node),
- "bad cursor in Previous");
+ "Position cursor of Previous is bad");
declare
Node : constant Node_Access :=
is
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of Query_Element equals No_Element";
end if;
if Position.Node.Key = null
or else Position.Node.Element = null
then
- raise Program_Error;
+ raise Program_Error with
+ "Position cursor of Query_Element is bad";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
- "bad cursor in Query_Element");
+ "Position cursor of Query_Element is bad");
declare
T : Tree_Type renames Position.Container.Tree;
----------
procedure Read
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Container : out Map)
is
function Read_Node
end Read;
procedure Read
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Item : out Cursor)
is
begin
- raise Program_Error;
+ raise Program_Error with "attempt to stream map cursor";
end Read;
-------------
begin
if Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "key not in map";
end if;
if Container.Tree.Lock > 0 then
- raise Program_Error;
+ raise Program_Error with
+ "attempt to tamper with cursors (map is locked)";
end if;
K := Node.Key;
is
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of Replace_Element equals No_Element";
end if;
if Position.Node.Key = null
or else Position.Node.Element = null
then
- raise Program_Error;
+ raise Program_Error with
+ "Position cursor of Replace_Element is bad";
end if;
if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error;
+ raise Program_Error with
+ "Position cursor of Replace_Element designates wrong map";
end if;
if Container.Tree.Lock > 0 then
- raise Program_Error;
+ raise Program_Error with
+ "attempt to tamper with cursors (map is locked)";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
- "bad cursor in Replace_Element");
+ "Position cursor of Replace_Element is bad");
declare
X : Element_Access := Position.Node.Element;
is
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of Update_Element equals No_Element";
end if;
if Position.Node.Key = null
or else Position.Node.Element = null
then
- raise Program_Error;
+ raise Program_Error with
+ "Position cursor of Update_Element is bad";
end if;
if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error;
+ raise Program_Error with
+ "Position cursor of Update_Element designates wrong map";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
- "bad cursor in Update_Element");
+ "Position cursor of Update_Element is bad");
declare
T : Tree_Type renames Position.Container.Tree;
-----------
procedure Write
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Container : Map)
is
procedure Write_Node
end Write;
procedure Write
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Item : Cursor)
is
begin
- raise Program_Error;
+ raise Program_Error with "attempt to stream map cursor";
end Write;
end Ada.Containers.Indefinite_Ordered_Maps;
end record;
procedure Write
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Item : Cursor);
for Cursor'Write use Write;
procedure Read
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Item : out Cursor);
for Cursor'Read use Read;
No_Element : constant Cursor := Cursor'(null, null);
procedure Write
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Container : Map);
for Map'Write use Write;
procedure Read
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Container : out Map);
for Map'Read use Read;
--------------
function New_Node (Next : Node_Access) return Node_Access is
- Node : Node_Access := new Node_Type; -- Ada 2005 aggregate possible?
-
begin
- Node.Key := Key;
- Node.Next := Next;
-
- return Node;
-
- exception
- when others =>
- Free (Node);
- raise;
+ return new Node_Type'(Key => Key,
+ Element => <>,
+ Next => Next);
end New_Node;
HT : Hash_Table_Type renames Container.HT;
--------------
function New_Node (Next : Node_Access) return Node_Access is
- Node : constant Node_Access := new Node_Type'(Key, New_Item, Next);
begin
- return Node;
+ return new Node_Type'(Key, New_Item, Next);
end New_Node;
HT : Hash_Table_Type renames Container.HT;
Node : Node_Access;
end record;
- procedure Write
- (Stream : access Root_Stream_Type'Class;
- Item : Cursor);
-
- for Cursor'Write use Write;
-
procedure Read
(Stream : access Root_Stream_Type'Class;
Item : out Cursor);
for Cursor'Read use Read;
+ procedure Write
+ (Stream : access Root_Stream_Type'Class;
+ Item : Cursor);
+
+ for Cursor'Write use Write;
+
No_Element : constant Cursor := (Container => null, Node => null);
end Ada.Containers.Hashed_Maps;
J := Target.Last;
while Source.Last >= Index_Type'First loop
+ pragma Assert
+ (Source.Last <= Index_Type'First
+ or else not (Is_Less
+ (Source.Elements (Source.Last),
+ Source.Elements (Source.Last - 1))));
+
if I < Index_Type'First then
declare
Src : Elements_Type renames
return;
end if;
+ pragma Assert
+ (I <= Index_Type'First
+ or else not (Is_Less
+ (Target.Elements (I),
+ Target.Elements (I - 1))));
+
declare
Src : Element_Access renames Source.Elements (Source.Last);
Tgt : Element_Access renames Target.Elements (I);
J := Target.Last;
while Source.Last >= Index_Type'First loop
+ pragma Assert (Source.Last <= Index_Type'First
+ or else not (Source.Elements (Source.Last) <
+ Source.Elements (Source.Last - 1)));
+
if I < Index_Type'First then
Target.Elements (Index_Type'First .. J) :=
Source.Elements (Index_Type'First .. Source.Last);
return;
end if;
+ pragma Assert (I <= Index_Type'First
+ or else not (Target.Elements (I) <
+ Target.Elements (I - 1)));
+
if Source.Elements (Source.Last) < Target.Elements (I) then
Target.Elements (J) := Target.Elements (I);
I := I - 1;
B : Natural renames V.Busy;
begin
-
B := B + 1;
begin
end;
B := B - 1;
-
end Reverse_Iterate;
----------------
function "<" (Left, Right : Cursor) return Boolean is
begin
- if Left.Node = null
- or else Right.Node = null
- then
- raise Constraint_Error;
+ if Left.Node = null then
+ raise Constraint_Error with "Left cursor of ""<"" equals No_Element";
+ end if;
+
+ if Right.Node = null then
+ raise Constraint_Error with "Right cursor of ""<"" equals No_Element";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
- "bad Left cursor in ""<""");
+ "Left cursor of ""<"" is bad");
pragma Assert (Vet (Right.Container.Tree, Right.Node),
- "bad Right cursor in ""<""");
+ "Right cursor of ""<"" is bad");
return Left.Node.Key < Right.Node.Key;
end "<";
function "<" (Left : Cursor; Right : Key_Type) return Boolean is
begin
if Left.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "Left cursor of ""<"" equals No_Element";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
- "bad Left cursor in ""<""");
+ "Left cursor of ""<"" is bad");
return Left.Node.Key < Right;
end "<";
function "<" (Left : Key_Type; Right : Cursor) return Boolean is
begin
if Right.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "Right cursor of ""<"" equals No_Element";
end if;
pragma Assert (Vet (Right.Container.Tree, Right.Node),
- "bad Right cursor in ""<""");
+ "Right cursor of ""<"" is bad");
return Left < Right.Node.Key;
end "<";
function ">" (Left, Right : Cursor) return Boolean is
begin
- if Left.Node = null
- or else Right.Node = null
- then
- raise Constraint_Error;
+ if Left.Node = null then
+ raise Constraint_Error with "Left cursor of "">"" equals No_Element";
+ end if;
+
+ if Right.Node = null then
+ raise Constraint_Error with "Right cursor of "">"" equals No_Element";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
- "bad Left cursor in "">""");
+ "Left cursor of "">"" is bad");
pragma Assert (Vet (Right.Container.Tree, Right.Node),
- "bad Right cursor in "">""");
+ "Right cursor of "">"" is bad");
return Right.Node.Key < Left.Node.Key;
end ">";
function ">" (Left : Cursor; Right : Key_Type) return Boolean is
begin
if Left.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "Left cursor of "">"" equals No_Element";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
- "bad Left cursor in "">""");
+ "Left cursor of "">"" is bad");
return Right < Left.Node.Key;
end ">";
function ">" (Left : Key_Type; Right : Cursor) return Boolean is
begin
if Right.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "Right cursor of "">"" equals No_Element";
end if;
pragma Assert (Vet (Right.Container.Tree, Right.Node),
- "bad Right cursor in "">""");
+ "Right cursor of "">"" is bad");
return Right.Node.Key < Left;
end ">";
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of Delete equals No_Element";
end if;
if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error;
+ raise Program_Error with
+ "Position cursor of Delete designates wrong map";
end if;
- pragma Assert (Vet (Tree, Position.Node), "bad cursor in Delete");
+ pragma Assert (Vet (Tree, Position.Node),
+ "Position cursor of Delete is bad");
Tree_Operations.Delete_Node_Sans_Free (Tree, Position.Node);
Free (Position.Node);
begin
if X = null then
- raise Constraint_Error;
+ raise Constraint_Error with "key not in map";
end if;
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
function Element (Position : Cursor) return Element_Type is
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of function Element equals No_Element";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
- "bad cursor in Element");
+ "Position cursor of function Element is bad");
return Position.Node.Element;
end Element;
begin
if Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "key not in map";
end if;
return Node.Element;
begin
if T.First = null then
- raise Constraint_Error;
+ raise Constraint_Error with "map is empty";
end if;
return T.First.Element;
begin
if T.First = null then
- raise Constraint_Error;
+ raise Constraint_Error with "map is empty";
end if;
return T.First.Key;
if not Inserted then
if Container.Tree.Lock > 0 then
- raise Program_Error;
+ raise Program_Error with
+ "attempt to tamper with cursors (map is locked)";
end if;
Position.Node.Key := Key;
Insert (Container, Key, New_Item, Position, Inserted);
if not Inserted then
- raise Constraint_Error;
+ raise Constraint_Error with "key already in map";
end if;
end Insert;
function Key (Position : Cursor) return Key_Type is
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of function Key equals No_Element";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
- "bad cursor in Key");
+ "Position cursor of function Key is bad");
return Position.Node.Key;
end Key;
begin
if T.Last = null then
- raise Constraint_Error;
+ raise Constraint_Error with "map is empty";
end if;
return T.Last.Element;
begin
if T.Last = null then
- raise Constraint_Error;
+ raise Constraint_Error with "map is empty";
end if;
return T.Last.Key;
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
- "bad cursor in Next");
+ "Position cursor of Next is bad");
declare
Node : constant Node_Access :=
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
- "bad cursor in Previous");
+ "Position cursor of Previous is bad");
declare
Node : constant Node_Access :=
is
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of Query_Element equals No_Element";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
- "bad cursor in Query_Element");
+ "Position cursor of Query_Element is bad");
declare
T : Tree_Type renames Position.Container.Tree;
----------
procedure Read
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Container : out Map)
is
function Read_Node
end Read;
procedure Read
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Item : out Cursor)
is
begin
- raise Program_Error;
+ raise Program_Error with "attempt to stream map cursor";
end Read;
-------------
begin
if Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with "key not in map";
end if;
if Container.Tree.Lock > 0 then
- raise Program_Error;
+ raise Program_Error with
+ "attempt to tamper with cursors (map is locked)";
end if;
Node.Key := Key;
is
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of Replace_Element equals No_Element";
end if;
if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error;
+ raise Program_Error with
+ "Position cursor of Replace_Element designates wrong map";
end if;
if Container.Tree.Lock > 0 then
- raise Program_Error;
+ raise Program_Error with
+ "attempt to tamper with cursors (map is locked)";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
- "bad cursor in Replace_Element");
+ "Position cursor of Replace_Element is bad");
Position.Node.Element := New_Item;
end Replace_Element;
is
begin
if Position.Node = null then
- raise Constraint_Error;
+ raise Constraint_Error with
+ "Position cursor of Update_Element equals No_Element";
end if;
if Position.Container /= Container'Unrestricted_Access then
- raise Program_Error;
+ raise Program_Error with
+ "Position cursor of Update_Element designates wrong map";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
- "bad cursor in Update_Element");
+ "Position cursor of Update_Element is bad");
declare
T : Tree_Type renames Container.Tree;
-----------
procedure Write
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Container : Map)
is
procedure Write_Node
end Write;
procedure Write
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Item : Cursor)
is
begin
- raise Program_Error;
+ raise Program_Error with "attempt to stream map cursor";
end Write;
end Ada.Containers.Ordered_Maps;
end record;
procedure Write
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Item : Cursor);
for Cursor'Write use Write;
procedure Read
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Item : out Cursor);
for Cursor'Read use Read;
No_Element : constant Cursor := Cursor'(null, null);
procedure Write
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Container : Map);
for Map'Write use Write;
procedure Read
- (Stream : access Root_Stream_Type'Class;
+ (Stream : not null access Root_Stream_Type'Class;
Container : out Map);
for Map'Read use Read;