Class DS_TRAVERSABLE PreviousNext

note
description:

    "Data structures that can be traversed. Traversable containers %
    %are equipped with an internal cursor and external cursors which %
    %can be used for simultaneous traversals."

library:    "Gobo Eiffel Structure Library"
author:     "Eric Bezault <ericb@gobosoft.com>"
copyright:  "Copyright (c) 1999-2001, Eric Bezault and others"
license:    "MIT License"
deferred class interface
DS_TRAVERSABLE [G]
inherit
DS_CONTAINER [G]
feature {NONE} -- Initialization
make_default
        -- Create an empty container.
        -- (From DS_CONTAINER.)
    deferred
    ensure
        empty: is_empty
feature -- Access
item_for_iteration: G
        -- Item at internal cursor position
    require
        not_off: not off
new_cursor: DS_CURSOR [G]
        -- New external cursor for traversal
    deferred
    ensure
        cursor_not_void: Result /= Void
        valid_cursor: valid_cursor (Result)
feature -- Measurement
count: INTEGER
        -- Number of items in container
        -- (From DS_CONTAINER.)
    deferred
feature -- Status report
is_empty: BOOLEAN
        -- Is container empty?
        -- (From DS_CONTAINER.)
off: BOOLEAN
        -- Is there no item at internal cursor position?
same_position (a_cursor: like new_cursor): BOOLEAN
        -- Is internal cursor at same position as a_cursor?
    require
        a_cursor_not_void: a_cursor /= Void
valid_cursor (a_cursor: DS_CURSOR [G]): BOOLEAN
        -- Is a_cursor a valid cursor?
    require
        a_cursor_not_void: a_cursor /= Void
feature -- Comparison
is_equal (other: like Current): BOOLEAN
        -- Is current container equal to other?
        -- (From GENERAL.)
    require
        other_not_void: other /= Void
    deferred
    ensure
        consistent: standard_is_equal (other) implies Result
        same_type: Result implies same_type (other)
        symmetric: Result implies other.is_equal (Current)
        same_count: Result implies count = other.count
feature -- Duplication
copy (other: like Current)
        -- Copy other to current container.
        -- (From GENERAL.)
    require
        other_not_void: other /= Void
        type_identity: same_type (other)
    deferred
    ensure
        is_equal: is_equal (other)
feature -- Cursor movement
go_to (a_cursor: like new_cursor)
        -- Move internal cursor to a_cursor's position.
    require
        cursor_not_void: a_cursor /= Void
        valid_cursor: valid_cursor (a_cursor)
    ensure
        same_position: same_position (a_cursor)
feature -- Removal
wipe_out
        -- Remove all items from container.
        -- (From DS_CONTAINER.)
    deferred
    ensure
        wiped_out: is_empty
invariant
positive_count: count >= 0
empty_definition: is_empty = (count = 0)
    -- (From DS_CONTAINER.)
empty_constraint: is_empty implies off
end -- class DS_TRAVERSABLE

Copyright © 1999-2001, Eric Bezault
mailto:
ericb@gobosoft.com
http:
//www.gobosoft.com
Last Updated: 31 March 2001

HomeTocPreviousNext