indexing
description: "Cursors for dynamically modifiable structure traversals"
library: "Gobo Eiffel Structure Library"
author: "Eric Bezault <ericb@gobo.demon.co.uk>"
copyright: "Copyright (c) 1997, Eric Bezault"
deferred class interface
DS_DYNAMIC_CURSOR [G]
feature -- Access
container: DS_TRAVERSABLE [G]
-- Structure traversed
-- (from DS_CURSOR)
item: G
-- Item at cursor position
-- (from DS_CURSOR)
require -- from DS_CURSOR
valid_cursor: is_valid;
not_off: not off
feature -- Status report
is_valid: BOOLEAN
-- Is cursor valid?
-- (A cursor might become invalid if container
-- has been modified during traversal.)
-- (from DS_CURSOR)
off: BOOLEAN
-- Is there no item at cursor position?
-- (from DS_CURSOR)
require -- from DS_CURSOR
valid_cursor: is_valid
feature -- Element change
put (v: G)
-- Replace item at cursor position by v.
require
valid_cursor: is_valid;
not_off: not off
ensure
replaced: item = v
feature -- Transformation
swap (other: like Current)
-- Exchange items at current and other positions.
-- Note: cursors may reference two different structures.
require
valid_cursor: is_valid;
not_off: not off;
other_not_void: other /= void;
valid_other: other.is_valid;
other_not_off: not other.off
ensure
new_item: item = old other.item;
new_other: other.item = old item
invariant
-- from GENERAL
reflexive_equality: standard_is_equal (Current);
reflexive_conformance: conforms_to (Current);
-- from DS_CURSOR
container_not_void: container /= void;
empty_constraint: container.is_empty implies off;
end -- class DS_DYNAMIC_CURSOR