Class DS_DYNAMIC_CURSOR |

    note

>     description:

>         "Cursors for dynamically modifiable data structure traversals"

>     library:    "Gobo Eiffel Structure Library"
>     copyright:  "Copyright (c) 1999, Eric Bezault and others"
>     license:    "MIT License"

    deferred class interface

>     DS_DYNAMIC_CURSOR [G]

    inherit

>     DS_CURSOR [G]

    feature -- Access

>     item: G
>             -- Item at cursor position
>             -- (From DS_CURSOR.)
>         require
>             not_off: not off
>         deferred

>     container: DS_TRAVERSABLE [G]
>             -- Data structure traversed
>             -- (From DS_CURSOR.)
>         deferred

    feature -- Status report

>     off: BOOLEAN
>             -- Is there no item at cursor position?
>             -- (From DS_CURSOR.)
>         deferred

>     same_position (other: like Current): BOOLEAN
>             -- Is current cursor at same position as other?
>             -- (From DS_CURSOR.)
>         require
>             other_not_void: other /= Void
>         deferred

    feature -- Cursor movement

>     go_to (other: like Current)
>             -- Move cursor to other's position.
>             -- (From DS_CURSOR.)
>         require
>             other_not_void: other /= Void
>             valid_cursor: container.valid_cursor (other)
>         deferred
>         ensure
>             same_position: same_position (other)

    feature -- Comparison

>     is_equal (other: like Current): BOOLEAN
>             -- Are other and current cursor at the same position?
>             -- (From GENERAL.)
>         require
>             other_not_void: other /= Void
>         ensure
>             consistent: standard_is_equal (other) implies Result
>             same_type: Result implies same_type (other)
>             symmetric: Result implies other.is_equal (Current)

    feature -- Duplication

>     copy (other: like Current)
>             -- Copy other to current cursor.
>             -- (From GENERAL.)
>         require
>             other_not_void: other /= Void
>             type_identity: same_type (other)
>         ensure
>             is_equal: is_equal (other)

    feature -- Element change

>     replace (v: G)
>             -- Replace item at cursor position by v.
>         require
>             not_off: not off
>         deferred
>         ensure
>             replaced: item = v

>     swap (other: DS_DYNAMIC_CURSOR [G])
>             -- Exchange items at current and other's positions.
>             -- Note: cursors may reference two different containers.
>         require
>             not_off: not off
>             other_not_void: other /= Void
>             other_not_off: not other.off
>         ensure
>             new_item: item = old (other.item)
>             new_other: other.item = old item

    invariant

>     container_not_void: container /= Void
>     empty_constraint: container.is_empty implies off
>         -- (From DS_CURSOR.)

    end -- class DS_DYNAMIC_CURSOR