indexing description: "Structures whose items may be accessed sequentially, one-way" names: sequential, traversing access: membership contents: generic deferred class interface LINEAR [G] feature -- Access has (v: like item): BOOLEAN -- Does structure include an occurrence of v? -- (Reference or object equality, -- based on object_comparison.) ensure -- from CONTAINER not_found_in_empty: Result implies not empty index: INTEGER -- Index of current position index_of (v: like item; i: INTEGER): INTEGER -- Index of i-th occurrence of v. -- 0 if none. -- (Reference or object equality, -- based on object_comparison.) require positive_occurrences: i > 0 ensure non_negative_result: Result >= 0 item: G -- Item at current position -- (from TRAVERSABLE) require -- from TRAVERSABLE not_off: not off occurrences (v: G): INTEGER -- Number of times v appears. -- (Reference or object equality, -- based on object_comparison.) search (v: like item) -- Move to first position (at or after current -- position) where item and v are equal. -- (Reference or object equality, -- based on object_comparison.) -- If no such position ensure that exhausted will be true. ensure object_found: (not exhausted and object_comparison) implies equal (v, item); item_found: (not exhausted and not object_comparison) implies v = item feature -- Status report after: BOOLEAN -- Is there no valid position to the right of current one? changeable_comparison_criterion: BOOLEAN -- May object_comparison be changed? -- (Answer: yes by default.) -- (from CONTAINER) empty: BOOLEAN -- Is there no element? -- (from CONTAINER) exhausted: BOOLEAN -- Has structure been completely explored? ensure exhausted_when_off: off implies Result object_comparison: BOOLEAN -- Must search operations use equal rather than = -- for comparing references? (Default: no, use =.) -- (from CONTAINER) off: BOOLEAN -- Is there no current item? feature -- Status setting compare_objects -- Ensure that future search operations will use equal -- rather than = for comparing references. -- (from CONTAINER) require -- from CONTAINER changeable_comparison_criterion ensure -- from CONTAINER object_comparison compare_references -- Ensure that future search operations will use = -- rather than equal for comparing references. -- (from CONTAINER) require -- from CONTAINER changeable_comparison_criterion ensure -- from CONTAINER reference_comparison: not object_comparison feature -- Cursor movement finish -- Move to last position. forth -- Move to next position; if no next position, -- ensure that exhausted will be true. require not_after: not after start -- Move to first position if any. -- (from TRAVERSABLE) feature -- Conversion linear_representation: LINEAR [G] -- Representation as a linear structure invariant -- from GENERAL reflexive_equality: standard_is_equal (Current); reflexive_conformance: conforms_to (Current); after_constraint: after implies off; -- from TRAVERSABLE empty_constraint: empty implies off; end -- class LINEAR