Index: src/natools-constant_indefinite_ordered_maps.adb ================================================================== --- src/natools-constant_indefinite_ordered_maps.adb +++ src/natools-constant_indefinite_ordered_maps.adb @@ -570,10 +570,28 @@ 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; @@ -726,6 +744,42 @@ 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; Index: src/natools-constant_indefinite_ordered_maps.ads ================================================================== --- src/natools-constant_indefinite_ordered_maps.ads +++ src/natools-constant_indefinite_ordered_maps.ads @@ -171,10 +171,13 @@ 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; @@ -340,12 +343,41 @@ 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;