407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
procedure Clear (Container : in out Constant_Map) is
begin
Container.Backend.Reset;
end Clear;
function Contains (Container : Constant_Map; Key : Key_Type)
return Boolean
is
Floor, Ceiling : Count_Type;
begin
if Container.Is_Empty then
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
|
procedure Clear (Container : in out Constant_Map) is
begin
Container.Backend.Reset;
end Clear;
function Constant_Reference
(Container : aliased in Constant_Map;
Position : in Cursor)
return Constant_Reference_Type
is
use type Backend_Refs.Immutable_Reference;
begin
if Position.Is_Empty then
raise Constraint_Error
with "Constant_Reference called with empty Position";
end if;
if Container.Backend /= Position.Backend then
raise Program_Error with "Constant_Reference called"
& " with unrelated Container and Position";
end if;
return
(Backend => Container.Backend,
Element => Container.Backend.Query.Data.all.Nodes
(Position.Index).Element);
end Constant_Reference;
function Constant_Reference
(Container : aliased in Constant_Map;
Key : in Key_Type)
return Constant_Reference_Type
is
Position : constant Cursor := Container.Find (Key);
begin
if Position.Is_Empty then
raise Constraint_Error
with "Constant_Reference called with Key not in map";
end if;
return
(Backend => Container.Backend,
Element => Container.Backend.Query.Data.Nodes
(Position.Index).Element);
end Constant_Reference;
function Contains (Container : Constant_Map; Key : Key_Type)
return Boolean
is
Floor, Ceiling : Count_Type;
begin
if Container.Is_Empty then
|
512
513
514
515
516
517
518
519
520
521
522
523
524
525
|
for I in Container.Backend.Query.Data.Nodes'Range loop
Position.Index := I;
Process.all (Position);
end loop;
end Iterate;
function Last (Container : Constant_Map) return Cursor is
begin
if Container.Is_Empty then
return No_Element;
else
return (Is_Empty => False,
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
for I in Container.Backend.Query.Data.Nodes'Range loop
Position.Index := I;
Process.all (Position);
end loop;
end Iterate;
function Iterate (Container : in Constant_Map)
return Map_Iterator_Interfaces.Reversible_Iterator'Class is
begin
return Iterator'(Backend => Container.Backend, Start => No_Element);
end Iterate;
function Iterate (Container : in Constant_Map; Start : in Cursor)
return Map_Iterator_Interfaces.Reversible_Iterator'Class is
begin
return Iterator'(Backend => Container.Backend, Start => Start);
end Iterate;
function Last (Container : Constant_Map) return Cursor is
begin
if Container.Is_Empty then
return No_Element;
else
return (Is_Empty => False,
|
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
|
end Reverse_Iterate;
------------------------------
-- Updatable Map Operations --
------------------------------
procedure Update_Element
(Container : in out Updatable_Map;
Position : in Cursor;
Process : not null access procedure (Key : in Key_Type;
Element : in out Element_Type))
is
Accessor : constant Backend_Refs.Accessor := Position.Backend.Query;
begin
Process.all
(Accessor.Data.Nodes (Position.Index).Key.all,
Accessor.Data.Nodes (Position.Index).Element.all);
end Update_Element;
end Natools.Constant_Indefinite_Ordered_Maps;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
|
end Reverse_Iterate;
------------------------------
-- Updatable Map Operations --
------------------------------
function Reference
(Container : aliased in out Updatable_Map;
Position : in Cursor)
return Reference_Type
is
use type Backend_Refs.Immutable_Reference;
begin
if Position.Is_Empty then
raise Constraint_Error with "Reference called with empty Position";
end if;
if Container.Backend /= Position.Backend then
raise Program_Error
with "Reference called with unrelated Container and Position";
end if;
return
(Backend => Container.Backend,
Element => Container.Backend.Query.Data.Nodes
(Position.Index).Element);
end Reference;
function Reference
(Container : aliased in out Updatable_Map;
Key : in Key_Type)
return Reference_Type
is
Position : constant Cursor := Container.Find (Key);
begin
if Position.Is_Empty then
raise Constraint_Error with "Reference called with Key not in map";
end if;
return
(Backend => Container.Backend,
Element => Container.Backend.Query.Data.Nodes
(Position.Index).Element);
end Reference;
procedure Update_Element
(Container : in out Updatable_Map;
Position : in Cursor;
Process : not null access procedure (Key : in Key_Type;
Element : in out Element_Type))
is
Accessor : constant Backend_Refs.Accessor := Position.Backend.Query;
begin
Process.all
(Accessor.Data.Nodes (Position.Index).Key.all,
Accessor.Data.Nodes (Position.Index).Element.all);
end Update_Element;
-------------------------
-- Iterator Operations --
-------------------------
overriding function First (Object : Iterator) return Cursor is
begin
if Has_Element (Object.Start) then
return Object.Start;
elsif Object.Backend.Is_Empty then
return No_Element;
else
return (Is_Empty => False,
Backend => Object.Backend,
Index => 1);
end if;
end First;
overriding function Last (Object : Iterator) return Cursor is
begin
if Has_Element (Object.Start) then
return Object.Start;
elsif Object.Backend.Is_Empty then
return No_Element;
else
return (Is_Empty => False,
Backend => Object.Backend,
Index => Object.Backend.Query.Data.Size);
end if;
end Last;
end Natools.Constant_Indefinite_Ordered_Maps;
|