Overview
Comment: | constant_indefinite_ordered_maps: add a reversible interator that operates on a sub-range of the map |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d7573547c06bc8e4cc205b7a55bbabea |
User & Date: | nat on 2014-12-14 19:11:33 |
Other Links: | manifest | tags |
Context
2014-12-15
| ||
22:40 | constant_indefinite_ordered_map_tests: add a fully-covering test of the new range iterator feature check-in: 98083b9906 user: nat tags: trunk | |
2014-12-14
| ||
19:11 | constant_indefinite_ordered_maps: add a reversible interator that operates on a sub-range of the map check-in: d7573547c0 user: nat tags: trunk | |
2014-12-02
| ||
22:07 | s_expressions: add usual lexicographical comparison operator on Atoms, so that clients don't have to explicitly use Ada.Streams."<" check-in: 62ca3fd9c9 user: nat tags: trunk | |
Changes
Modified src/natools-constant_indefinite_ordered_maps.adb from [d509c86522] to [e2501f2237].
︙ | ︙ | |||
568 569 570 571 572 573 574 575 576 577 578 579 580 581 | 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, | > > > > > > > > > > > > > > > > > > | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | 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 Iterate (Container : in Constant_Map; First, Last : in Cursor) return Map_Iterator_Interfaces.Reversible_Iterator'Class is begin if Is_Empty (Container) or else not Has_Element (First) or else not Has_Element (Last) or else First > Last then return Iterator'(Backend => Backend_Refs.Null_Immutable_Reference, Start => No_Element); else return Range_Iterator'(Backend => Container.Backend, First_Position => First, Last_Position => Last); end if; end Iterate; function Last (Container : Constant_Map) return Cursor is begin if Container.Is_Empty then return No_Element; else return (Is_Empty => False, |
︙ | ︙ | |||
724 725 726 727 728 729 730 731 | else return (Is_Empty => False, Backend => Object.Backend, Index => Object.Backend.Query.Data.Size); end if; end Last; end Natools.Constant_Indefinite_Ordered_Maps; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 | else return (Is_Empty => False, Backend => Object.Backend, Index => Object.Backend.Query.Data.Size); end if; end Last; overriding function First (Object : Range_Iterator) return Cursor is begin return Object.First_Position; end First; overriding function Last (Object : Range_Iterator) return Cursor is begin return Object.Last_Position; end Last; overriding function Next (Object : Range_Iterator; Position : Cursor) return Cursor is begin if Has_Element (Position) and then Position < Object.Last_Position then return Next (Position); else return No_Element; end if; end Next; overriding function Previous (Object : Range_Iterator; Position : Cursor) return Cursor is begin if Has_Element (Position) and then Position > Object.First_Position then return Previous (Position); else return No_Element; end if; end Previous; end Natools.Constant_Indefinite_Ordered_Maps; |
Modified src/natools-constant_indefinite_ordered_maps.ads from [6c929df40a] to [784866a661].
︙ | ︙ | |||
169 170 171 172 173 174 175 176 177 178 179 180 181 182 | function Iterate (Container : in Constant_Map) return Map_Iterator_Interfaces.Reversible_Iterator'Class; function Iterate (Container : in Constant_Map; Start : in Cursor) return Map_Iterator_Interfaces.Reversible_Iterator'Class; type Constant_Reference_Type (Element : not null access constant Element_Type) is private with Implicit_Dereference => Element; function Constant_Reference (Container : aliased in Constant_Map; | > > > | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | function Iterate (Container : in Constant_Map) return Map_Iterator_Interfaces.Reversible_Iterator'Class; function Iterate (Container : in Constant_Map; Start : in Cursor) return Map_Iterator_Interfaces.Reversible_Iterator'Class; function Iterate (Container : in Constant_Map; First, Last : in Cursor) return Map_Iterator_Interfaces.Reversible_Iterator'Class; type Constant_Reference_Type (Element : not null access constant Element_Type) is private with Implicit_Dereference => Element; function Constant_Reference (Container : aliased in Constant_Map; |
︙ | ︙ | |||
338 339 340 341 342 343 344 345 346 347 348 349 350 351 | with Pre => Position.Is_Empty or else Backend_Refs."=" (Position.Backend, Object.Backend); overriding function Previous (Object : Iterator; Position : Cursor) return Cursor is (Previous (Position)) with Pre => Position.Is_Empty or else Backend_Refs."=" (Position.Backend, Object.Backend); No_Element : constant Cursor := (Is_Empty => True); end Natools.Constant_Indefinite_Ordered_Maps; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | with Pre => Position.Is_Empty or else Backend_Refs."=" (Position.Backend, Object.Backend); overriding function Previous (Object : Iterator; Position : Cursor) return Cursor is (Previous (Position)) with Pre => Position.Is_Empty or else Backend_Refs."=" (Position.Backend, Object.Backend); type Range_Iterator is new Map_Iterator_Interfaces.Reversible_Iterator with record Backend : Backend_Refs.Immutable_Reference; First_Position : Cursor; Last_Position : Cursor; end record; -- with Dynamic_Predicate => not Range_Iterator.Backend.Is_Empty -- and then Has_Element (Range_Iterator.First_Position) -- and then Has_Element (Range_Iterator.Last_Position) -- and then not Range_Iterator.First_Position -- > Range_Iterator.Last_Position; overriding function First (Object : Range_Iterator) return Cursor; overriding function Last (Object : Range_Iterator) return Cursor; overriding function Next (Object : Range_Iterator; Position : Cursor) return Cursor with Pre => Position.Is_Empty or else Backend_Refs."=" (Position.Backend, Object.Backend); overriding function Previous (Object : Range_Iterator; Position : Cursor) return Cursor with Pre => Position.Is_Empty or else Backend_Refs."=" (Position.Backend, Object.Backend); No_Element : constant Cursor := (Is_Empty => True); end Natools.Constant_Indefinite_Ordered_Maps; |