1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- A D A . C O N T A I N E R S . B O U N D E D _ O R D E R E D _ M A P S --
9 -- Copyright (C) 2004-2011, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- This unit was originally developed by Matthew J Heaney. --
28 ------------------------------------------------------------------------------
30 with Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations;
32 (Ada.Containers.Red_Black_Trees.Generic_Bounded_Operations);
34 with Ada.Containers.Red_Black_Trees.Generic_Bounded_Keys;
36 (Ada.Containers.Red_Black_Trees.Generic_Bounded_Keys);
38 with System; use type System.Address;
40 package body Ada.Containers.Bounded_Ordered_Maps is
43 Map_Iterator_Interfaces.Reversible_Iterator with record
44 Container : Map_Access;
48 overriding function First (Object : Iterator) return Cursor;
50 overriding function Last (Object : Iterator) return Cursor;
52 overriding function Next
54 Position : Cursor) return Cursor;
56 overriding function Previous
58 Position : Cursor) return Cursor;
60 -----------------------------
61 -- Node Access Subprograms --
62 -----------------------------
64 -- These subprograms provide a functional interface to access fields
65 -- of a node, and a procedural interface for modifying these values.
67 function Color (Node : Node_Type) return Color_Type;
68 pragma Inline (Color);
70 function Left (Node : Node_Type) return Count_Type;
73 function Parent (Node : Node_Type) return Count_Type;
74 pragma Inline (Parent);
76 function Right (Node : Node_Type) return Count_Type;
77 pragma Inline (Right);
79 procedure Set_Parent (Node : in out Node_Type; Parent : Count_Type);
80 pragma Inline (Set_Parent);
82 procedure Set_Left (Node : in out Node_Type; Left : Count_Type);
83 pragma Inline (Set_Left);
85 procedure Set_Right (Node : in out Node_Type; Right : Count_Type);
86 pragma Inline (Set_Right);
88 procedure Set_Color (Node : in out Node_Type; Color : Color_Type);
89 pragma Inline (Set_Color);
91 -----------------------
92 -- Local Subprograms --
93 -----------------------
95 function Is_Greater_Key_Node
97 Right : Node_Type) return Boolean;
98 pragma Inline (Is_Greater_Key_Node);
100 function Is_Less_Key_Node
102 Right : Node_Type) return Boolean;
103 pragma Inline (Is_Less_Key_Node);
105 --------------------------
106 -- Local Instantiations --
107 --------------------------
109 package Tree_Operations is
110 new Red_Black_Trees.Generic_Bounded_Operations (Tree_Types);
115 new Red_Black_Trees.Generic_Bounded_Keys
116 (Tree_Operations => Tree_Operations,
117 Key_Type => Key_Type,
118 Is_Less_Key_Node => Is_Less_Key_Node,
119 Is_Greater_Key_Node => Is_Greater_Key_Node);
125 function "<" (Left, Right : Cursor) return Boolean is
127 if Left.Node = 0 then
128 raise Constraint_Error with "Left cursor of ""<"" equals No_Element";
131 if Right.Node = 0 then
132 raise Constraint_Error with "Right cursor of ""<"" equals No_Element";
135 pragma Assert (Vet (Left.Container.all, Left.Node),
136 "Left cursor of ""<"" is bad");
138 pragma Assert (Vet (Right.Container.all, Right.Node),
139 "Right cursor of ""<"" is bad");
142 LN : Node_Type renames Left.Container.Nodes (Left.Node);
143 RN : Node_Type renames Right.Container.Nodes (Right.Node);
146 return LN.Key < RN.Key;
150 function "<" (Left : Cursor; Right : Key_Type) return Boolean is
152 if Left.Node = 0 then
153 raise Constraint_Error with "Left cursor of ""<"" equals No_Element";
156 pragma Assert (Vet (Left.Container.all, Left.Node),
157 "Left cursor of ""<"" is bad");
160 LN : Node_Type renames Left.Container.Nodes (Left.Node);
163 return LN.Key < Right;
167 function "<" (Left : Key_Type; Right : Cursor) return Boolean is
169 if Right.Node = 0 then
170 raise Constraint_Error with "Right cursor of ""<"" equals No_Element";
173 pragma Assert (Vet (Right.Container.all, Right.Node),
174 "Right cursor of ""<"" is bad");
177 RN : Node_Type renames Right.Container.Nodes (Right.Node);
180 return Left < RN.Key;
188 function "=" (Left, Right : Map) return Boolean is
189 function Is_Equal_Node_Node (L, R : Node_Type) return Boolean;
190 pragma Inline (Is_Equal_Node_Node);
193 new Tree_Operations.Generic_Equal (Is_Equal_Node_Node);
195 ------------------------
196 -- Is_Equal_Node_Node --
197 ------------------------
199 function Is_Equal_Node_Node
200 (L, R : Node_Type) return Boolean is
202 if L.Key < R.Key then
205 elsif R.Key < L.Key then
209 return L.Element = R.Element;
211 end Is_Equal_Node_Node;
213 -- Start of processing for "="
216 return Is_Equal (Left, Right);
223 function ">" (Left, Right : Cursor) return Boolean is
225 if Left.Node = 0 then
226 raise Constraint_Error with "Left cursor of "">"" equals No_Element";
229 if Right.Node = 0 then
230 raise Constraint_Error with "Right cursor of "">"" equals No_Element";
233 pragma Assert (Vet (Left.Container.all, Left.Node),
234 "Left cursor of "">"" is bad");
236 pragma Assert (Vet (Right.Container.all, Right.Node),
237 "Right cursor of "">"" is bad");
240 LN : Node_Type renames Left.Container.Nodes (Left.Node);
241 RN : Node_Type renames Right.Container.Nodes (Right.Node);
244 return RN.Key < LN.Key;
248 function ">" (Left : Cursor; Right : Key_Type) return Boolean is
250 if Left.Node = 0 then
251 raise Constraint_Error with "Left cursor of "">"" equals No_Element";
254 pragma Assert (Vet (Left.Container.all, Left.Node),
255 "Left cursor of "">"" is bad");
258 LN : Node_Type renames Left.Container.Nodes (Left.Node);
260 return Right < LN.Key;
264 function ">" (Left : Key_Type; Right : Cursor) return Boolean is
266 if Right.Node = 0 then
267 raise Constraint_Error with "Right cursor of "">"" equals No_Element";
270 pragma Assert (Vet (Right.Container.all, Right.Node),
271 "Right cursor of "">"" is bad");
274 RN : Node_Type renames Right.Container.Nodes (Right.Node);
277 return RN.Key < Left;
285 procedure Assign (Target : in out Map; Source : Map) is
286 procedure Append_Element (Source_Node : Count_Type);
288 procedure Append_Elements is
289 new Tree_Operations.Generic_Iteration (Append_Element);
295 procedure Append_Element (Source_Node : Count_Type) is
296 SN : Node_Type renames Source.Nodes (Source_Node);
298 procedure Set_Element (Node : in out Node_Type);
299 pragma Inline (Set_Element);
301 function New_Node return Count_Type;
302 pragma Inline (New_Node);
304 procedure Insert_Post is
305 new Key_Ops.Generic_Insert_Post (New_Node);
307 procedure Unconditional_Insert_Sans_Hint is
308 new Key_Ops.Generic_Unconditional_Insert (Insert_Post);
310 procedure Unconditional_Insert_Avec_Hint is
311 new Key_Ops.Generic_Unconditional_Insert_With_Hint
313 Unconditional_Insert_Sans_Hint);
315 procedure Allocate is
316 new Tree_Operations.Generic_Allocate (Set_Element);
322 function New_Node return Count_Type is
326 Allocate (Target, Result);
334 procedure Set_Element (Node : in out Node_Type) is
337 Node.Element := SN.Element;
340 Target_Node : Count_Type;
342 -- Start of processing for Append_Element
345 Unconditional_Insert_Avec_Hint
349 Node => Target_Node);
352 -- Start of processing for Assign
355 if Target'Address = Source'Address then
359 if Target.Capacity < Source.Length then
361 with "Target capacity is less than Source length";
364 Tree_Operations.Clear_Tree (Target);
365 Append_Elements (Source);
372 function Ceiling (Container : Map; Key : Key_Type) return Cursor is
373 Node : constant Count_Type := Key_Ops.Ceiling (Container, Key);
380 return Cursor'(Container'Unrestricted_Access, Node);
387 procedure Clear (Container : in out Map) is
389 Tree_Operations.Clear_Tree (Container);
396 function Color (Node : Node_Type) return Color_Type is
405 function Contains (Container : Map; Key : Key_Type) return Boolean is
407 return Find (Container, Key) /= No_Element;
414 function Copy (Source : Map; Capacity : Count_Type := 0) return Map is
421 elsif Capacity >= Source.Length then
425 raise Capacity_Error with "Capacity value too small";
428 return Target : Map (Capacity => C) do
429 Assign (Target => Target, Source => Source);
437 procedure Delete (Container : in out Map; Position : in out Cursor) is
439 if Position.Node = 0 then
440 raise Constraint_Error with
441 "Position cursor of Delete equals No_Element";
444 if Position.Container /= Container'Unrestricted_Access then
445 raise Program_Error with
446 "Position cursor of Delete designates wrong map";
449 pragma Assert (Vet (Container, Position.Node),
450 "Position cursor of Delete is bad");
452 Tree_Operations.Delete_Node_Sans_Free (Container, Position.Node);
453 Tree_Operations.Free (Container, Position.Node);
455 Position := No_Element;
458 procedure Delete (Container : in out Map; Key : Key_Type) is
459 X : constant Count_Type := Key_Ops.Find (Container, Key);
463 raise Constraint_Error with "key not in map";
466 Tree_Operations.Delete_Node_Sans_Free (Container, X);
467 Tree_Operations.Free (Container, X);
474 procedure Delete_First (Container : in out Map) is
475 X : constant Count_Type := Container.First;
479 Tree_Operations.Delete_Node_Sans_Free (Container, X);
480 Tree_Operations.Free (Container, X);
488 procedure Delete_Last (Container : in out Map) is
489 X : constant Count_Type := Container.Last;
493 Tree_Operations.Delete_Node_Sans_Free (Container, X);
494 Tree_Operations.Free (Container, X);
502 function Element (Position : Cursor) return Element_Type is
504 if Position.Node = 0 then
505 raise Constraint_Error with
506 "Position cursor of function Element equals No_Element";
509 pragma Assert (Vet (Position.Container.all, Position.Node),
510 "Position cursor of function Element is bad");
512 return Position.Container.Nodes (Position.Node).Element;
515 function Element (Container : Map; Key : Key_Type) return Element_Type is
516 Node : constant Count_Type := Key_Ops.Find (Container, Key);
519 raise Constraint_Error with "key not in map";
521 return Container.Nodes (Node).Element;
525 ---------------------
526 -- Equivalent_Keys --
527 ---------------------
529 function Equivalent_Keys (Left, Right : Key_Type) return Boolean is
544 procedure Exclude (Container : in out Map; Key : Key_Type) is
545 X : constant Count_Type := Key_Ops.Find (Container, Key);
549 Tree_Operations.Delete_Node_Sans_Free (Container, X);
550 Tree_Operations.Free (Container, X);
558 function Find (Container : Map; Key : Key_Type) return Cursor is
559 Node : constant Count_Type := Key_Ops.Find (Container, Key);
564 return Cursor'(Container'Unrestricted_Access, Node);
572 function First (Container : Map) return Cursor is
574 if Container.First = 0 then
577 return Cursor'(Container'Unrestricted_Access, Container.First);
581 function First (Object : Iterator) return Cursor is
582 F : constant Count_Type := Object.Container.First;
587 return Cursor'(Object.Container.all'Unchecked_Access, F);
595 function First_Element (Container : Map) return Element_Type is
597 if Container.First = 0 then
598 raise Constraint_Error with "map is empty";
600 return Container.Nodes (Container.First).Element;
608 function First_Key (Container : Map) return Key_Type is
610 if Container.First = 0 then
611 raise Constraint_Error with "map is empty";
613 return Container.Nodes (Container.First).Key;
621 function Floor (Container : Map; Key : Key_Type) return Cursor is
622 Node : constant Count_Type := Key_Ops.Floor (Container, Key);
627 return Cursor'(Container'Unrestricted_Access, Node);
635 function Has_Element (Position : Cursor) return Boolean is
637 return Position /= No_Element;
645 (Container : in out Map;
647 New_Item : Element_Type)
653 Insert (Container, Key, New_Item, Position, Inserted);
656 if Container.Lock > 0 then
657 raise Program_Error with
658 "attempt to tamper with elements (map is locked)";
662 N : Node_Type renames Container.Nodes (Position.Node);
665 N.Element := New_Item;
675 (Container : in out Map;
677 New_Item : Element_Type;
678 Position : out Cursor;
679 Inserted : out Boolean)
681 procedure Assign (Node : in out Node_Type);
682 pragma Inline (Assign);
684 function New_Node return Count_Type;
685 pragma Inline (New_Node);
687 procedure Insert_Post is
688 new Key_Ops.Generic_Insert_Post (New_Node);
690 procedure Insert_Sans_Hint is
691 new Key_Ops.Generic_Conditional_Insert (Insert_Post);
693 procedure Allocate is
694 new Tree_Operations.Generic_Allocate (Assign);
700 procedure Assign (Node : in out Node_Type) is
703 Node.Element := New_Item;
710 function New_Node return Count_Type is
713 Allocate (Container, Result);
717 -- Start of processing for Insert
726 Position.Container := Container'Unrestricted_Access;
730 (Container : in out Map;
732 New_Item : Element_Type)
735 pragma Unreferenced (Position);
740 Insert (Container, Key, New_Item, Position, Inserted);
743 raise Constraint_Error with "key already in map";
748 (Container : in out Map;
750 Position : out Cursor;
751 Inserted : out Boolean)
753 procedure Assign (Node : in out Node_Type);
754 pragma Inline (Assign);
756 function New_Node return Count_Type;
757 pragma Inline (New_Node);
759 procedure Insert_Post is
760 new Key_Ops.Generic_Insert_Post (New_Node);
762 procedure Insert_Sans_Hint is
763 new Key_Ops.Generic_Conditional_Insert (Insert_Post);
765 procedure Allocate is
766 new Tree_Operations.Generic_Allocate (Assign);
772 procedure Assign (Node : in out Node_Type) is
776 -- Were this insertion operation to accept an element parameter, this
777 -- is the point where the element value would be used, to update the
778 -- element component of the new node. However, this insertion
779 -- operation is special, in the sense that it does not accept an
780 -- element parameter. Rather, this version of Insert allocates a node
781 -- (inserting it among the active nodes of the container in the
782 -- normal way, with the node's position being determined by the Key),
783 -- and passes back a cursor designating the node. It is then up to
784 -- the caller to assign a value to the node's element.
786 -- Node.Element := New_Item;
793 function New_Node return Count_Type is
796 Allocate (Container, Result);
800 -- Start of processing for Insert
809 Position.Container := Container'Unrestricted_Access;
816 function Is_Empty (Container : Map) return Boolean is
818 return Container.Length = 0;
821 -------------------------
822 -- Is_Greater_Key_Node --
823 -------------------------
825 function Is_Greater_Key_Node
827 Right : Node_Type) return Boolean
830 -- Left > Right same as Right < Left
832 return Right.Key < Left;
833 end Is_Greater_Key_Node;
835 ----------------------
836 -- Is_Less_Key_Node --
837 ----------------------
839 function Is_Less_Key_Node
841 Right : Node_Type) return Boolean
844 return Left < Right.Key;
845 end Is_Less_Key_Node;
853 Process : not null access procedure (Position : Cursor))
855 procedure Process_Node (Node : Count_Type);
856 pragma Inline (Process_Node);
858 procedure Local_Iterate is
859 new Tree_Operations.Generic_Iteration (Process_Node);
865 procedure Process_Node (Node : Count_Type) is
867 Process (Cursor'(Container'Unrestricted_Access, Node));
870 B : Natural renames Container'Unrestricted_Access.all.Busy;
872 -- Start of processing for Iterate
878 Local_Iterate (Container);
889 (Container : Map) return Map_Iterator_Interfaces.Forward_Iterator'class
891 It : constant Iterator :=
892 (Container'Unrestricted_Access, Container.First);
900 return Map_Iterator_Interfaces.Reversible_Iterator'class
902 It : constant Iterator := (Container'Unrestricted_Access, Start.Node);
911 function Key (Position : Cursor) return Key_Type is
913 if Position.Node = 0 then
914 raise Constraint_Error with
915 "Position cursor of function Key equals No_Element";
918 pragma Assert (Vet (Position.Container.all, Position.Node),
919 "Position cursor of function Key is bad");
921 return Position.Container.Nodes (Position.Node).Key;
928 function Last (Container : Map) return Cursor is
930 if Container.Last = 0 then
933 return Cursor'(Container'Unrestricted_Access, Container.Last);
937 function Last (Object : Iterator) return Cursor is
938 F : constant Count_Type := Object.Container.Last;
943 return Cursor'(Object.Container.all'Unchecked_Access, F);
951 function Last_Element (Container : Map) return Element_Type is
953 if Container.Last = 0 then
954 raise Constraint_Error with "map is empty";
956 return Container.Nodes (Container.Last).Element;
964 function Last_Key (Container : Map) return Key_Type is
966 if Container.Last = 0 then
967 raise Constraint_Error with "map is empty";
969 return Container.Nodes (Container.Last).Key;
977 function Left (Node : Node_Type) return Count_Type is
986 function Length (Container : Map) return Count_Type is
988 return Container.Length;
995 procedure Move (Target : in out Map; Source : in out Map) is
997 if Target'Address = Source'Address then
1001 if Source.Busy > 0 then
1002 raise Program_Error with
1003 "attempt to tamper with cursors (container is busy)";
1006 Target.Assign (Source);
1014 procedure Next (Position : in out Cursor) is
1016 Position := Next (Position);
1019 function Next (Position : Cursor) return Cursor is
1021 if Position = No_Element then
1025 pragma Assert (Vet (Position.Container.all, Position.Node),
1026 "Position cursor of Next is bad");
1029 M : Map renames Position.Container.all;
1031 Node : constant Count_Type :=
1032 Tree_Operations.Next (M, Position.Node);
1039 return Cursor'(Position.Container, Node);
1045 Position : Cursor) return Cursor
1047 pragma Unreferenced (Object);
1049 return Next (Position);
1056 function Parent (Node : Node_Type) return Count_Type is
1065 procedure Previous (Position : in out Cursor) is
1067 Position := Previous (Position);
1070 function Previous (Position : Cursor) return Cursor is
1072 if Position = No_Element then
1076 pragma Assert (Vet (Position.Container.all, Position.Node),
1077 "Position cursor of Previous is bad");
1080 M : Map renames Position.Container.all;
1082 Node : constant Count_Type :=
1083 Tree_Operations.Previous (M, Position.Node);
1090 return Cursor'(Position.Container, Node);
1096 Position : Cursor) return Cursor
1098 pragma Unreferenced (Object);
1100 return Previous (Position);
1107 procedure Query_Element
1109 Process : not null access procedure (Key : Key_Type;
1110 Element : Element_Type))
1113 if Position.Node = 0 then
1114 raise Constraint_Error with
1115 "Position cursor of Query_Element equals No_Element";
1118 pragma Assert (Vet (Position.Container.all, Position.Node),
1119 "Position cursor of Query_Element is bad");
1122 M : Map renames Position.Container.all;
1123 N : Node_Type renames M.Nodes (Position.Node);
1125 B : Natural renames M.Busy;
1126 L : Natural renames M.Lock;
1133 Process (N.Key, N.Element);
1151 (Stream : not null access Root_Stream_Type'Class;
1152 Container : out Map)
1154 procedure Read_Element (Node : in out Node_Type);
1155 pragma Inline (Read_Element);
1157 procedure Allocate is
1158 new Tree_Operations.Generic_Allocate (Read_Element);
1160 procedure Read_Elements is
1161 new Tree_Operations.Generic_Read (Allocate);
1167 procedure Read_Element (Node : in out Node_Type) is
1169 Key_Type'Read (Stream, Node.Key);
1170 Element_Type'Read (Stream, Node.Element);
1173 -- Start of processing for Read
1176 Read_Elements (Stream, Container);
1180 (Stream : not null access Root_Stream_Type'Class;
1184 raise Program_Error with "attempt to stream map cursor";
1188 (Stream : not null access Root_Stream_Type'Class;
1189 Item : out Reference_Type)
1192 raise Program_Error with "attempt to stream reference";
1196 (Stream : not null access Root_Stream_Type'Class;
1197 Item : out Constant_Reference_Type)
1200 raise Program_Error with "attempt to stream reference";
1207 function Constant_Reference
1209 Key : Key_Type) return Constant_Reference_Type
1212 return (Element => Container.Element (Key)'Unrestricted_Access);
1213 end Constant_Reference;
1217 Key : Key_Type) return Reference_Type
1220 return (Element => Container.Element (Key)'Unrestricted_Access);
1228 (Container : in out Map;
1230 New_Item : Element_Type)
1232 Node : constant Count_Type := Key_Ops.Find (Container, Key);
1236 raise Constraint_Error with "key not in map";
1239 if Container.Lock > 0 then
1240 raise Program_Error with
1241 "attempt to tamper with elements (map is locked)";
1245 N : Node_Type renames Container.Nodes (Node);
1249 N.Element := New_Item;
1253 ---------------------
1254 -- Replace_Element --
1255 ---------------------
1257 procedure Replace_Element
1258 (Container : in out Map;
1260 New_Item : Element_Type)
1263 if Position.Node = 0 then
1264 raise Constraint_Error with
1265 "Position cursor of Replace_Element equals No_Element";
1268 if Position.Container /= Container'Unrestricted_Access then
1269 raise Program_Error with
1270 "Position cursor of Replace_Element designates wrong map";
1273 if Container.Lock > 0 then
1274 raise Program_Error with
1275 "attempt to tamper with elements (map is locked)";
1278 pragma Assert (Vet (Container, Position.Node),
1279 "Position cursor of Replace_Element is bad");
1281 Container.Nodes (Position.Node).Element := New_Item;
1282 end Replace_Element;
1284 ---------------------
1285 -- Reverse_Iterate --
1286 ---------------------
1288 procedure Reverse_Iterate
1290 Process : not null access procedure (Position : Cursor))
1292 procedure Process_Node (Node : Count_Type);
1293 pragma Inline (Process_Node);
1295 procedure Local_Reverse_Iterate is
1296 new Tree_Operations.Generic_Reverse_Iteration (Process_Node);
1302 procedure Process_Node (Node : Count_Type) is
1304 Process (Cursor'(Container'Unrestricted_Access, Node));
1307 B : Natural renames Container'Unrestricted_Access.all.Busy;
1309 -- Start of processing for Reverse_Iterate
1315 Local_Reverse_Iterate (Container);
1323 end Reverse_Iterate;
1329 function Right (Node : Node_Type) return Count_Type is
1339 (Node : in out Node_Type;
1343 Node.Color := Color;
1350 procedure Set_Left (Node : in out Node_Type; Left : Count_Type) is
1359 procedure Set_Parent (Node : in out Node_Type; Parent : Count_Type) is
1361 Node.Parent := Parent;
1368 procedure Set_Right (Node : in out Node_Type; Right : Count_Type) is
1370 Node.Right := Right;
1373 --------------------
1374 -- Update_Element --
1375 --------------------
1377 procedure Update_Element
1378 (Container : in out Map;
1380 Process : not null access procedure (Key : Key_Type;
1381 Element : in out Element_Type))
1384 if Position.Node = 0 then
1385 raise Constraint_Error with
1386 "Position cursor of Update_Element equals No_Element";
1389 if Position.Container /= Container'Unrestricted_Access then
1390 raise Program_Error with
1391 "Position cursor of Update_Element designates wrong map";
1394 pragma Assert (Vet (Container, Position.Node),
1395 "Position cursor of Update_Element is bad");
1398 N : Node_Type renames Container.Nodes (Position.Node);
1399 B : Natural renames Container.Busy;
1400 L : Natural renames Container.Lock;
1407 Process (N.Key, N.Element);
1426 (Stream : not null access Root_Stream_Type'Class;
1429 procedure Write_Node
1430 (Stream : not null access Root_Stream_Type'Class;
1432 pragma Inline (Write_Node);
1434 procedure Write_Nodes is
1435 new Tree_Operations.Generic_Write (Write_Node);
1441 procedure Write_Node
1442 (Stream : not null access Root_Stream_Type'Class;
1446 Key_Type'Write (Stream, Node.Key);
1447 Element_Type'Write (Stream, Node.Element);
1450 -- Start of processing for Write
1453 Write_Nodes (Stream, Container);
1457 (Stream : not null access Root_Stream_Type'Class;
1461 raise Program_Error with "attempt to stream map cursor";
1465 (Stream : not null access Root_Stream_Type'Class;
1466 Item : Reference_Type)
1469 raise Program_Error with "attempt to stream reference";
1473 (Stream : not null access Root_Stream_Type'Class;
1474 Item : Constant_Reference_Type)
1477 raise Program_Error with "attempt to stream reference";
1480 end Ada.Containers.Bounded_Ordered_Maps;