1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- ADA.CONTAINERS.RESTRICTED_DOUBLY_LINKED_LISTS --
9 -- Copyright (C) 2004-2009, 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 System; use type System.Address;
32 package body Ada.Containers.Restricted_Doubly_Linked_Lists is
34 -----------------------
35 -- Local Subprograms --
36 -----------------------
39 (Container : in out List'Class;
40 New_Item : Element_Type;
41 New_Node : out Count_Type);
44 (Container : in out List'Class;
47 procedure Insert_Internal
48 (Container : in out List'Class;
50 New_Node : Count_Type);
52 function Vet (Position : Cursor) return Boolean;
58 function "=" (Left, Right : List) return Boolean is
59 LN : Node_Array renames Left.Nodes;
60 RN : Node_Array renames Right.Nodes;
62 LI : Count_Type := Left.First;
63 RI : Count_Type := Right.First;
66 if Left'Address = Right'Address then
70 if Left.Length /= Right.Length then
74 for J in 1 .. Left.Length loop
75 if LN (LI).Element /= RN (RI).Element then
91 (Container : in out List'Class;
92 New_Item : Element_Type;
93 New_Node : out Count_Type)
95 N : Node_Array renames Container.Nodes;
98 if Container.Free >= 0 then
99 New_Node := Container.Free;
100 N (New_Node).Element := New_Item;
101 Container.Free := N (New_Node).Next;
104 New_Node := abs Container.Free;
105 N (New_Node).Element := New_Item;
106 Container.Free := Container.Free - 1;
115 (Container : in out List;
116 New_Item : Element_Type;
117 Count : Count_Type := 1)
120 Insert (Container, No_Element, New_Item, Count);
127 procedure Assign (Target : in out List; Source : List) is
129 if Target'Address = Source'Address then
133 if Target.Capacity < Source.Length then
134 raise Constraint_Error; -- ???
140 N : Node_Array renames Source.Nodes;
141 J : Count_Type := Source.First;
145 Append (Target, N (J).Element);
155 procedure Clear (Container : in out List) is
156 N : Node_Array renames Container.Nodes;
160 if Container.Length = 0 then
161 pragma Assert (Container.First = 0);
162 pragma Assert (Container.Last = 0);
163 -- pragma Assert (Container.Busy = 0);
164 -- pragma Assert (Container.Lock = 0);
168 pragma Assert (Container.First >= 1);
169 pragma Assert (Container.Last >= 1);
170 pragma Assert (N (Container.First).Prev = 0);
171 pragma Assert (N (Container.Last).Next = 0);
173 -- if Container.Busy > 0 then
174 -- raise Program_Error;
177 while Container.Length > 1 loop
178 X := Container.First;
180 Container.First := N (X).Next;
181 N (Container.First).Prev := 0;
183 Container.Length := Container.Length - 1;
188 X := Container.First;
190 Container.First := 0;
192 Container.Length := 0;
203 Item : Element_Type) return Boolean
206 return Find (Container, Item) /= No_Element;
214 (Container : in out List;
215 Position : in out Cursor;
216 Count : Count_Type := 1)
218 N : Node_Array renames Container.Nodes;
222 if Position.Node = 0 then
223 raise Constraint_Error;
226 if Position.Container /= Container'Unrestricted_Access then
230 pragma Assert (Vet (Position), "bad cursor in Delete");
232 if Position.Node = Container.First then
233 Delete_First (Container, Count);
234 Position := No_Element;
239 Position := No_Element;
243 -- if Container.Busy > 0 then
244 -- raise Program_Error;
247 pragma Assert (Container.First >= 1);
248 pragma Assert (Container.Last >= 1);
249 pragma Assert (N (Container.First).Prev = 0);
250 pragma Assert (N (Container.Last).Next = 0);
252 for Index in 1 .. Count loop
253 pragma Assert (Container.Length >= 2);
256 Container.Length := Container.Length - 1;
258 if X = Container.Last then
259 Position := No_Element;
261 Container.Last := N (X).Prev;
262 N (Container.Last).Next := 0;
268 Position.Node := N (X).Next;
270 N (N (X).Next).Prev := N (X).Prev;
271 N (N (X).Prev).Next := N (X).Next;
276 Position := No_Element;
283 procedure Delete_First
284 (Container : in out List;
285 Count : Count_Type := 1)
287 N : Node_Array renames Container.Nodes;
291 if Count >= Container.Length then
300 -- if Container.Busy > 0 then
301 -- raise Program_Error;
304 for I in 1 .. Count loop
305 X := Container.First;
306 pragma Assert (N (N (X).Next).Prev = Container.First);
308 Container.First := N (X).Next;
309 N (Container.First).Prev := 0;
311 Container.Length := Container.Length - 1;
321 procedure Delete_Last
322 (Container : in out List;
323 Count : Count_Type := 1)
325 N : Node_Array renames Container.Nodes;
329 if Count >= Container.Length then
338 -- if Container.Busy > 0 then
339 -- raise Program_Error;
342 for I in 1 .. Count loop
344 pragma Assert (N (N (X).Prev).Next = Container.Last);
346 Container.Last := N (X).Prev;
347 N (Container.Last).Next := 0;
349 Container.Length := Container.Length - 1;
359 function Element (Position : Cursor) return Element_Type is
361 if Position.Node = 0 then
362 raise Constraint_Error;
365 pragma Assert (Vet (Position), "bad cursor in Element");
368 N : Node_Array renames Position.Container.Nodes;
370 return N (Position.Node).Element;
381 Position : Cursor := No_Element) return Cursor
383 Nodes : Node_Array renames Container.Nodes;
384 Node : Count_Type := Position.Node;
388 Node := Container.First;
391 if Position.Container /= Container'Unrestricted_Access then
395 pragma Assert (Vet (Position), "bad cursor in Find");
399 if Nodes (Node).Element = Item then
400 return Cursor'(Container'Unrestricted_Access, Node);
403 Node := Nodes (Node).Next;
413 function First (Container : List) return Cursor is
415 if Container.First = 0 then
419 return Cursor'(Container'Unrestricted_Access, Container.First);
426 function First_Element (Container : List) return Element_Type is
427 N : Node_Array renames Container.Nodes;
430 if Container.First = 0 then
431 raise Constraint_Error;
434 return N (Container.First).Element;
442 (Container : in out List'Class;
445 pragma Assert (X > 0);
446 pragma Assert (X <= Container.Capacity);
448 N : Node_Array renames Container.Nodes;
451 N (X).Prev := -1; -- Node is deallocated (not on active list)
453 if Container.Free >= 0 then
454 N (X).Next := Container.Free;
457 elsif X + 1 = abs Container.Free then
458 N (X).Next := 0; -- Not strictly necessary, but marginally safer
459 Container.Free := Container.Free + 1;
462 Container.Free := abs Container.Free;
464 if Container.Free > Container.Capacity then
468 for I in Container.Free .. Container.Capacity - 1 loop
472 N (Container.Capacity).Next := 0;
475 N (X).Next := Container.Free;
480 ---------------------
481 -- Generic_Sorting --
482 ---------------------
484 package body Generic_Sorting is
490 function Is_Sorted (Container : List) return Boolean is
491 Nodes : Node_Array renames Container.Nodes;
492 Node : Count_Type := Container.First;
495 for I in 2 .. Container.Length loop
496 if Nodes (Nodes (Node).Next).Element < Nodes (Node).Element then
500 Node := Nodes (Node).Next;
510 procedure Sort (Container : in out List) is
511 N : Node_Array renames Container.Nodes;
513 procedure Partition (Pivot, Back : Count_Type);
514 procedure Sort (Front, Back : Count_Type);
520 procedure Partition (Pivot, Back : Count_Type) is
521 Node : Count_Type := N (Pivot).Next;
524 while Node /= Back loop
525 if N (Node).Element < N (Pivot).Element then
527 Prev : constant Count_Type := N (Node).Prev;
528 Next : constant Count_Type := N (Node).Next;
531 N (Prev).Next := Next;
534 Container.Last := Prev;
536 N (Next).Prev := Prev;
539 N (Node).Next := Pivot;
540 N (Node).Prev := N (Pivot).Prev;
542 N (Pivot).Prev := Node;
544 if N (Node).Prev = 0 then
545 Container.First := Node;
547 N (N (Node).Prev).Next := Node;
554 Node := N (Node).Next;
563 procedure Sort (Front, Back : Count_Type) is
564 Pivot : constant Count_Type :=
565 (if Front = 0 then Container.First else N (Front).Next);
567 if Pivot /= Back then
568 Partition (Pivot, Back);
574 -- Start of processing for Sort
577 if Container.Length <= 1 then
581 pragma Assert (N (Container.First).Prev = 0);
582 pragma Assert (N (Container.Last).Next = 0);
584 -- if Container.Busy > 0 then
585 -- raise Program_Error;
588 Sort (Front => 0, Back => 0);
590 pragma Assert (N (Container.First).Prev = 0);
591 pragma Assert (N (Container.Last).Next = 0);
600 function Has_Element (Position : Cursor) return Boolean is
602 pragma Assert (Vet (Position), "bad cursor in Has_Element");
603 return Position.Node /= 0;
611 (Container : in out List;
613 New_Item : Element_Type;
614 Position : out Cursor;
615 Count : Count_Type := 1)
620 if Before.Container /= null then
621 if Before.Container /= Container'Unrestricted_Access then
625 pragma Assert (Vet (Before), "bad cursor in Insert");
633 if Container.Length > Container.Capacity - Count then
634 raise Constraint_Error;
637 -- if Container.Busy > 0 then
638 -- raise Program_Error;
641 Allocate (Container, New_Item, New_Node => J);
642 Insert_Internal (Container, Before.Node, New_Node => J);
643 Position := Cursor'(Container'Unrestricted_Access, Node => J);
645 for Index in 2 .. Count loop
646 Allocate (Container, New_Item, New_Node => J);
647 Insert_Internal (Container, Before.Node, New_Node => J);
652 (Container : in out List;
654 New_Item : Element_Type;
655 Count : Count_Type := 1)
658 pragma Unreferenced (Position);
660 Insert (Container, Before, New_Item, Position, Count);
664 (Container : in out List;
666 Position : out Cursor;
667 Count : Count_Type := 1)
669 New_Item : Element_Type; -- Do we need to reinit node ???
670 pragma Warnings (Off, New_Item);
673 Insert (Container, Before, New_Item, Position, Count);
676 ---------------------
677 -- Insert_Internal --
678 ---------------------
680 procedure Insert_Internal
681 (Container : in out List'Class;
683 New_Node : Count_Type)
685 N : Node_Array renames Container.Nodes;
688 if Container.Length = 0 then
689 pragma Assert (Before = 0);
690 pragma Assert (Container.First = 0);
691 pragma Assert (Container.Last = 0);
693 Container.First := New_Node;
694 Container.Last := New_Node;
696 N (Container.First).Prev := 0;
697 N (Container.Last).Next := 0;
699 elsif Before = 0 then
700 pragma Assert (N (Container.Last).Next = 0);
702 N (Container.Last).Next := New_Node;
703 N (New_Node).Prev := Container.Last;
705 Container.Last := New_Node;
706 N (Container.Last).Next := 0;
708 elsif Before = Container.First then
709 pragma Assert (N (Container.First).Prev = 0);
711 N (Container.First).Prev := New_Node;
712 N (New_Node).Next := Container.First;
714 Container.First := New_Node;
715 N (Container.First).Prev := 0;
718 pragma Assert (N (Container.First).Prev = 0);
719 pragma Assert (N (Container.Last).Next = 0);
721 N (New_Node).Next := Before;
722 N (New_Node).Prev := N (Before).Prev;
724 N (N (Before).Prev).Next := New_Node;
725 N (Before).Prev := New_Node;
728 Container.Length := Container.Length + 1;
735 function Is_Empty (Container : List) return Boolean is
737 return Container.Length = 0;
746 Process : not null access procedure (Position : Cursor))
748 C : List renames Container'Unrestricted_Access.all;
749 N : Node_Array renames C.Nodes;
750 -- B : Natural renames C.Busy;
752 Node : Count_Type := Container.First;
754 Index : Count_Type := 0;
755 Index_Max : constant Count_Type := Container.Length;
758 if Index_Max = 0 then
759 pragma Assert (Node = 0);
764 pragma Assert (Node /= 0);
766 Process (Cursor'(C'Unchecked_Access, Node));
767 pragma Assert (Container.Length = Index_Max);
768 pragma Assert (N (Node).Prev /= -1);
770 Node := N (Node).Next;
773 if Index = Index_Max then
774 pragma Assert (Node = 0);
784 function Last (Container : List) return Cursor is
786 if Container.Last = 0 then
790 return Cursor'(Container'Unrestricted_Access, Container.Last);
797 function Last_Element (Container : List) return Element_Type is
798 N : Node_Array renames Container.Nodes;
801 if Container.Last = 0 then
802 raise Constraint_Error;
805 return N (Container.Last).Element;
812 function Length (Container : List) return Count_Type is
814 return Container.Length;
821 procedure Next (Position : in out Cursor) is
823 Position := Next (Position);
826 function Next (Position : Cursor) return Cursor is
828 if Position.Node = 0 then
832 pragma Assert (Vet (Position), "bad cursor in Next");
835 Nodes : Node_Array renames Position.Container.Nodes;
836 Node : constant Count_Type := Nodes (Position.Node).Next;
843 return Cursor'(Position.Container, Node);
852 (Container : in out List;
853 New_Item : Element_Type;
854 Count : Count_Type := 1)
857 Insert (Container, First (Container), New_Item, Count);
864 procedure Previous (Position : in out Cursor) is
866 Position := Previous (Position);
869 function Previous (Position : Cursor) return Cursor is
871 if Position.Node = 0 then
875 pragma Assert (Vet (Position), "bad cursor in Previous");
878 Nodes : Node_Array renames Position.Container.Nodes;
879 Node : constant Count_Type := Nodes (Position.Node).Prev;
885 return Cursor'(Position.Container, Node);
893 procedure Query_Element
895 Process : not null access procedure (Element : Element_Type))
898 if Position.Node = 0 then
899 raise Constraint_Error;
902 pragma Assert (Vet (Position), "bad cursor in Query_Element");
905 C : List renames Position.Container.all'Unrestricted_Access.all;
906 N : Node_Type renames C.Nodes (Position.Node);
910 pragma Assert (N.Prev >= 0);
914 ---------------------
915 -- Replace_Element --
916 ---------------------
918 procedure Replace_Element
919 (Container : in out List;
921 New_Item : Element_Type)
924 if Position.Container = null then
925 raise Constraint_Error;
928 if Position.Container /= Container'Unrestricted_Access then
932 -- if Container.Lock > 0 then
933 -- raise Program_Error;
936 pragma Assert (Vet (Position), "bad cursor in Replace_Element");
939 N : Node_Array renames Container.Nodes;
941 N (Position.Node).Element := New_Item;
945 ----------------------
946 -- Reverse_Elements --
947 ----------------------
949 procedure Reverse_Elements (Container : in out List) is
950 N : Node_Array renames Container.Nodes;
951 I : Count_Type := Container.First;
952 J : Count_Type := Container.Last;
954 procedure Swap (L, R : Count_Type);
960 procedure Swap (L, R : Count_Type) is
961 LN : constant Count_Type := N (L).Next;
962 LP : constant Count_Type := N (L).Prev;
964 RN : constant Count_Type := N (R).Next;
965 RP : constant Count_Type := N (R).Prev;
980 pragma Assert (RP = L);
994 -- Start of processing for Reverse_Elements
997 if Container.Length <= 1 then
1001 pragma Assert (N (Container.First).Prev = 0);
1002 pragma Assert (N (Container.Last).Next = 0);
1004 -- if Container.Busy > 0 then
1005 -- raise Program_Error;
1008 Container.First := J;
1009 Container.Last := I;
1011 Swap (L => I, R => J);
1019 Swap (L => J, R => I);
1028 pragma Assert (N (Container.First).Prev = 0);
1029 pragma Assert (N (Container.Last).Next = 0);
1030 end Reverse_Elements;
1036 function Reverse_Find
1038 Item : Element_Type;
1039 Position : Cursor := No_Element) return Cursor
1041 N : Node_Array renames Container.Nodes;
1042 Node : Count_Type := Position.Node;
1046 Node := Container.Last;
1049 if Position.Container /= Container'Unrestricted_Access then
1050 raise Program_Error;
1053 pragma Assert (Vet (Position), "bad cursor in Reverse_Find");
1056 while Node /= 0 loop
1057 if N (Node).Element = Item then
1058 return Cursor'(Container'Unrestricted_Access, Node);
1061 Node := N (Node).Prev;
1067 ---------------------
1068 -- Reverse_Iterate --
1069 ---------------------
1071 procedure Reverse_Iterate
1073 Process : not null access procedure (Position : Cursor))
1075 C : List renames Container'Unrestricted_Access.all;
1076 N : Node_Array renames C.Nodes;
1077 -- B : Natural renames C.Busy;
1079 Node : Count_Type := Container.Last;
1081 Index : Count_Type := 0;
1082 Index_Max : constant Count_Type := Container.Length;
1085 if Index_Max = 0 then
1086 pragma Assert (Node = 0);
1091 pragma Assert (Node > 0);
1093 Process (Cursor'(C'Unchecked_Access, Node));
1094 pragma Assert (Container.Length = Index_Max);
1095 pragma Assert (N (Node).Prev /= -1);
1097 Node := N (Node).Prev;
1100 if Index = Index_Max then
1101 pragma Assert (Node = 0);
1105 end Reverse_Iterate;
1112 (Container : in out List;
1114 Position : in out Cursor)
1116 N : Node_Array renames Container.Nodes;
1119 if Before.Container /= null then
1120 if Before.Container /= Container'Unrestricted_Access then
1121 raise Program_Error;
1124 pragma Assert (Vet (Before), "bad Before cursor in Splice");
1127 if Position.Node = 0 then
1128 raise Constraint_Error;
1131 if Position.Container /= Container'Unrestricted_Access then
1132 raise Program_Error;
1135 pragma Assert (Vet (Position), "bad Position cursor in Splice");
1137 if Position.Node = Before.Node
1138 or else N (Position.Node).Next = Before.Node
1143 pragma Assert (Container.Length >= 2);
1145 -- if Container.Busy > 0 then
1146 -- raise Program_Error;
1149 if Before.Node = 0 then
1150 pragma Assert (Position.Node /= Container.Last);
1152 if Position.Node = Container.First then
1153 Container.First := N (Position.Node).Next;
1154 N (Container.First).Prev := 0;
1157 N (N (Position.Node).Prev).Next := N (Position.Node).Next;
1158 N (N (Position.Node).Next).Prev := N (Position.Node).Prev;
1161 N (Container.Last).Next := Position.Node;
1162 N (Position.Node).Prev := Container.Last;
1164 Container.Last := Position.Node;
1165 N (Container.Last).Next := 0;
1170 if Before.Node = Container.First then
1171 pragma Assert (Position.Node /= Container.First);
1173 if Position.Node = Container.Last then
1174 Container.Last := N (Position.Node).Prev;
1175 N (Container.Last).Next := 0;
1178 N (N (Position.Node).Prev).Next := N (Position.Node).Next;
1179 N (N (Position.Node).Next).Prev := N (Position.Node).Prev;
1182 N (Container.First).Prev := Position.Node;
1183 N (Position.Node).Next := Container.First;
1185 Container.First := Position.Node;
1186 N (Container.First).Prev := 0;
1191 if Position.Node = Container.First then
1192 Container.First := N (Position.Node).Next;
1193 N (Container.First).Prev := 0;
1195 elsif Position.Node = Container.Last then
1196 Container.Last := N (Position.Node).Prev;
1197 N (Container.Last).Next := 0;
1200 N (N (Position.Node).Prev).Next := N (Position.Node).Next;
1201 N (N (Position.Node).Next).Prev := N (Position.Node).Prev;
1204 N (N (Before.Node).Prev).Next := Position.Node;
1205 N (Position.Node).Prev := N (Before.Node).Prev;
1207 N (Before.Node).Prev := Position.Node;
1208 N (Position.Node).Next := Before.Node;
1210 pragma Assert (N (Container.First).Prev = 0);
1211 pragma Assert (N (Container.Last).Next = 0);
1219 (Container : in out List;
1226 raise Constraint_Error;
1229 if I.Container /= Container'Unrestricted_Access
1230 or else J.Container /= Container'Unrestricted_Access
1232 raise Program_Error;
1235 if I.Node = J.Node then
1239 -- if Container.Lock > 0 then
1240 -- raise Program_Error;
1243 pragma Assert (Vet (I), "bad I cursor in Swap");
1244 pragma Assert (Vet (J), "bad J cursor in Swap");
1247 N : Node_Array renames Container.Nodes;
1249 EI : Element_Type renames N (I.Node).Element;
1250 EJ : Element_Type renames N (J.Node).Element;
1252 EI_Copy : constant Element_Type := EI;
1264 procedure Swap_Links
1265 (Container : in out List;
1272 raise Constraint_Error;
1275 if I.Container /= Container'Unrestricted_Access
1276 or else I.Container /= J.Container
1278 raise Program_Error;
1281 if I.Node = J.Node then
1285 -- if Container.Busy > 0 then
1286 -- raise Program_Error;
1289 pragma Assert (Vet (I), "bad I cursor in Swap_Links");
1290 pragma Assert (Vet (J), "bad J cursor in Swap_Links");
1293 I_Next : constant Cursor := Next (I);
1295 J_Copy : Cursor := J;
1296 pragma Warnings (Off, J_Copy);
1300 Splice (Container, Before => I, Position => J_Copy);
1304 J_Next : constant Cursor := Next (J);
1306 I_Copy : Cursor := I;
1307 pragma Warnings (Off, I_Copy);
1311 Splice (Container, Before => J, Position => I_Copy);
1314 pragma Assert (Container.Length >= 3);
1316 Splice (Container, Before => I_Next, Position => J_Copy);
1317 Splice (Container, Before => J_Next, Position => I_Copy);
1324 --------------------
1325 -- Update_Element --
1326 --------------------
1328 procedure Update_Element
1329 (Container : in out List;
1331 Process : not null access procedure (Element : in out Element_Type))
1334 if Position.Node = 0 then
1335 raise Constraint_Error;
1338 if Position.Container /= Container'Unrestricted_Access then
1339 raise Program_Error;
1342 pragma Assert (Vet (Position), "bad cursor in Update_Element");
1345 N : Node_Type renames Container.Nodes (Position.Node);
1348 Process (N.Element);
1349 pragma Assert (N.Prev >= 0);
1357 function Vet (Position : Cursor) return Boolean is
1359 if Position.Node = 0 then
1360 return Position.Container = null;
1363 if Position.Container = null then
1368 L : List renames Position.Container.all;
1369 N : Node_Array renames L.Nodes;
1372 if L.Length = 0 then
1384 if Position.Node > L.Capacity then
1388 if N (Position.Node).Prev < 0
1389 or else N (Position.Node).Prev > L.Capacity
1394 if N (Position.Node).Next > L.Capacity then
1398 if N (L.First).Prev /= 0 then
1402 if N (L.Last).Next /= 0 then
1406 if N (Position.Node).Prev = 0
1407 and then Position.Node /= L.First
1412 if N (Position.Node).Next = 0
1413 and then Position.Node /= L.Last
1418 if L.Length = 1 then
1419 return L.First = L.Last;
1422 if L.First = L.Last then
1426 if N (L.First).Next = 0 then
1430 if N (L.Last).Prev = 0 then
1434 if N (N (L.First).Next).Prev /= L.First then
1438 if N (N (L.Last).Prev).Next /= L.Last then
1442 if L.Length = 2 then
1443 if N (L.First).Next /= L.Last then
1447 if N (L.Last).Prev /= L.First then
1454 if N (L.First).Next = L.Last then
1458 if N (L.Last).Prev = L.First then
1462 if Position.Node = L.First then
1466 if Position.Node = L.Last then
1470 if N (Position.Node).Next = 0 then
1474 if N (Position.Node).Prev = 0 then
1478 if N (N (Position.Node).Next).Prev /= Position.Node then
1482 if N (N (Position.Node).Prev).Next /= Position.Node then
1486 if L.Length = 3 then
1487 if N (L.First).Next /= Position.Node then
1491 if N (L.Last).Prev /= Position.Node then
1500 end Ada.Containers.Restricted_Doubly_Linked_Lists;