Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

structure.container

Class DS_TRAVERSABLE


Direct ancestors

DS_CONTAINER

Known direct descendants

DS_LINEAR

Features

Invariants

indexing

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

copyright

Copyright (c) 1999-2001, Eric Bezault and others

license

Eiffel Forum License v2 (see forum.txt)

date

$Date: 2003/02/07 12:58:08 $

revision

$Revision: 1.8 $

deferred class

DS_TRAVERSABLE [G]

inherit

DS_CONTAINER

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

ensure
cursor_not_void: Result /= Void
valid_cursor: valid_cursor (Result)

feature -- Measurement

count: INTEGER

-- Number of items in container

-- (From DS_CONTAINER)

feature -- Comparison

is_equal (other: like Current): BOOLEAN

-- Is current container equal to other?

-- (From ANY)

require
other_not_void: other /= Void
ensure
symmetric: Result implies other.is_equal (Current)
consistent: standard_is_equal (other) implies Result

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

ensure
wiped_out: is_empty

feature -- Duplication

cloned_object: like Current

-- Clone of current object

-- (From KL_CLONABLE)

ensure
cloned_not_void: Result /= Void
same_type: ANY_.same_types (Result, Current)
is_equal: Result.is_equal (Current)
copy (other: like Current)

-- Update current object using fields of object attached
-- to other, so as to yield equal objects.

-- (From ANY)

require
other_not_void: other /= Void
type_identity: same_type (other)
ensure
is_equal: is_equal (other)

feature {DS_CURSOR} -- Cursor implementation

add_traversing_cursor (a_cursor: like new_cursor)

-- Add a_cursor to the list of traversing cursors
-- (i.e. cursors associated with current container
-- and which are not currently off).

require
a_cursor_not_void: a_cursor /= Void
cursor_go_to (a_cursor, other: like new_cursor)

-- Move a_cursor to other's position.

require
cursor_not_void: a_cursor /= Void
a_cursor_valid: valid_cursor (a_cursor)
other_not_void: other /= Void
other_valid: valid_cursor (other)
ensure
same_position: cursor_same_position (a_cursor, other)
cursor_item (a_cursor: like new_cursor): G

-- Item at a_cursor position

require
a_cursor_not_void: a_cursor /= Void
a_cursor_valid: valid_cursor (a_cursor)
a_cursor_not_off: not cursor_off (a_cursor)
cursor_off (a_cursor: like new_cursor): BOOLEAN

-- Is there no item at a_cursor position?

require
a_cursor_not_void: a_cursor /= Void
a_cursor_valid: valid_cursor (a_cursor)
cursor_same_position (a_cursor, other: like new_cursor): BOOLEAN

-- Is a_cursor at same position as other?

require
a_cursor_not_void: a_cursor /= Void
a_cursor_valid: valid_cursor (a_cursor)
other_not_void: other /= Void
remove_traversing_cursor (a_cursor: like new_cursor)

-- Remove a_cursor from the list of traversing cursors
-- (i.e. cursors associated with current container
-- and which are not currently off).

require
a_cursor_not_void: a_cursor /= Void

invariant

empty_constraint: initialized implies (is_empty implies off)
internal_cursor_not_void: initialized implies (internal_cursor /= Void)
valid_internal_cursor: initialized implies valid_cursor (internal_cursor)

-- From DS_CONTAINER
positive_count: count >= 0
empty_definition: is_empty = (count = 0)

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end