indexing
	namespace: "candidate"
	cluster: "collection"
	description: "Bidirectional iterator for a collection"
	original_author: "Justin Finnerty"
	original_date: "August 2005"
	current_date: "$Date: 2005/09/03 01:39:35 $"
	current_author: "$Author: finnerty $"
	revision: "$Revision: 2.2 $"
	--  $Log: bilinear_cursor.e,v $
	--  Revision 2.2  2005/09/03 01:39:35  finnerty
	--  Updated to conform to cursors/containers in the GOBO library
	--
	--  Revision 2.1  2005/09/03 00:50:03  finnerty
	--  Renamed bidirectional_iterator to bilinear_cursor.
	--
	--  Revision 2.1  2005/09/02 07:24:32  finnerty
	--  Modified to work with VisualEiffel
	--
	--  Revision 2.0  2005/08/26 23:19:46  finnerty
	--  == alpha version ==
	--
	--  Revision 1.1  2005/08/06 12:29:49  finnerty
	--  Specialisation of iterator to allow bidirectional traversal
	--
deferred class BILINEAR_CURSOR[T_ITEM->TREE_NODE]
	-- Bidirectional iterator for a collection.

feature {ANY}
	-- Access
	item: T_ITEM is
			-- Item at cursor position
		require
        not_off: not off
		deferred
		end
			
	container: T_ITEM is
			-- Data structure traversed
		deferred
		end
	
feature {ANY}
	-- Status report
	is_first: BOOLEAN is
        -- Is cursor on first item?
    deferred
    ensure
        not_empty: Result implies not container.is_empty
        not_off: Result implies not off
        definition: Result implies (item = container.first)
	 end
	 
	 is_last: BOOLEAN is
			-- Is cursor on last item?
		deferred
		ensure
			not_empty: Result implies not container.is_empty
			not_off: Result implies not off
			definition: Result implies (item = container.last)
		end
	
	after: BOOLEAN is
			-- Is there no valid position to right of cursor?
		deferred
		end
	
	before: BOOLEAN is
			-- Is there no valid position to left of cursor?
		deferred
		end

	off: BOOLEAN is
			-- Is there no item at cursor position?
		deferred
		end
	
	same_position (other: like Current): BOOLEAN is
			-- Is current cursor at same position as other?
		require
			other_not_void: other /= Void
		deferred
		end
	
feature {ANY}
	-- Cursor movement
	start is
			-- Move cursor to first position.
		deferred
		ensure
			empty_behavior: container.is_empty implies after
			not_empty_behavior: not container.is_empty implies is_first
		end
	
	finish is
			-- Move cursor to last position.
		deferred
		ensure
        empty_behavior: container.is_empty implies before
        not_empty_behavior: not container.is_empty implies is_last
		end
	
	forth is
			-- Move cursor to next position.
		require
			not_after: not after
		deferred
		end
	
	back is
			-- Move cursor to previous position.
		require
			not_before: not before
		deferred
		end
	
	search_forth (v: T_ITEM) is
			-- 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.
		require
			not_off: not off or after
		deferred
		end
	
	search_back (v: T_ITEM) is
			-- Move to first position at or before current
			-- position where item and v are equal.
			-- (Use equality_tester's criterion from container
			-- if not void, use `=' criterion otherwise.)
			-- Move before if not found.
		require
			not_off: not off or before
		deferred
		end

	go_after is
			-- Move cursor to after position.
		deferred
		ensure
			after: after
		end
	
	go_before is
			-- Move cursor to before position.
		deferred
		ensure
			before: before
		end
	
	go_to (other: like Current) is
			-- Move cursor to other's position.
		require
			other_not_void: other /= Void
			valid_cursor: container = other.container
		deferred
		ensure
			same_position: same_position (other)
		end
	
invariant
	container_not_void: container /= Void
end -- class BILINEAR_CURSOR

