Class DS_SET_CURSOR |

    indexing

>     description:

>         "Cursors for set traversals"

>     library:    "Gobo Eiffel Structure Library"
>     author:     "Eric Bezault <ericb@gobosoft.com>"
>     copyright:  "Copyright (c) 2001, Eric Bezault and others"
>     license:    "Eiffel Forum License v2 (see forum.txt)"

    deferred class interface

>     DS_SET_CURSOR [G]

    inherit

>     DS_LINEAR_CURSOR [G]
>         DS_CURSOR [G]

    feature -- Access

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

>     container: DS_SET [G]
>             -- Set traversed
>             -- (From DS_CURSOR.)
>         deferred

    feature -- Status report

>     is_first: BOOLEAN
>             -- Is cursor on first item?
>             -- (From DS_LINEAR_CURSOR.)
>         deferred
>         ensure
>             not_empty: Result implies not container.is_empty
>             not_off: Result implies not off
>             definition: Result implies (item = container.first)

>     after: BOOLEAN
>             -- Is there no valid position to right of cursor?
>             -- (From DS_LINEAR_CURSOR.)
>         deferred

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

>     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

>     start
>             -- Move cursor to first position.
>             -- (From DS_LINEAR_CURSOR.)
>         deferred
>         ensure
>             empty_behavior: container.is_empty implies after
>             not_empty_behavior: not container.is_empty implies is_first

>     forth
>             -- Move cursor to next position.
>             -- (From DS_LINEAR_CURSOR.)
>         require
>             not_after: not after
>         deferred

>     search_forth (v: G)
>             -- Move to first position at or after current
>             -- position where item and v are equal.
>             -- (Use equality_tester's criterion from container
>             -- if not void, use `=' criterion otherwise.)
>             -- Move after if not found.
>             -- (From DS_LINEAR_CURSOR.)
>         require
>             not_off: not off or after
>         deferred

>     go_after
>             -- Move cursor to after position.
>             -- (From DS_LINEAR_CURSOR.)
>         deferred
>         ensure
>             after: after

>     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)

    invariant

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

>     after_constraint: after implies off
>         -- (From DS_LINEAR_CURSOR.)

    end -- class DS_SET_CURSOR