note
	description: "Sequential, two-way linked lists"
	library: "Free implementation of ELKS library"
	legal: "See notice at end of class."
	status: "See notice at end of class."
	names: two_way_list, sequence
	representation: linked
	access: index, cursor, membership
	contents: generic
	date: "$Date: 2018-11-14 15:15:17 +0000 (Wed, 14 Nov 2018) $"
	revision: "$Revision: 102463 $"

class interface
	TWO_WAY_LIST [G]

create 
	make,
	make_from_iterable


create {TWO_WAY_LIST}
	make_sublist

feature -- Access

	first_element: detachable like new_cell
			-- Head of list
			-- (Anchor redefinition)

	last_element: like first_element
			-- Tail of the list

	sublist: detachable like Current
			-- Result produced by last split

	cursor: TWO_WAY_LIST_CURSOR [G]
			-- Current cursor position

	new_cursor: TWO_WAY_LIST_ITERATION_CURSOR [G]
			-- Fresh cursor associated with current structure
	
feature -- Status report

	islast: BOOLEAN
			-- Is cursor at last position?
	
feature -- Cursor movement

	forth
			-- Move cursor to next position, if any.

	back
			-- Move cursor to previous position, if any.

	finish
			-- Move cursor to last position.
			-- (Go before if empty)
		ensure then
			not_after: not after

	move (i: INTEGER_32)
			-- Move cursor i positions. The cursor
			-- may end up off if the offset is to big.
	
feature -- Element change

	put_front (v: like item)
			-- Add v to beginning.
			-- Do not move cursor.

	extend (v: like item)
			-- Add v to end.
			-- Do not move cursor.

	put_left (v: like item)
			-- Add v to the left of cursor position.
			-- Do not move cursor.

	put_right (v: like item)
			-- Add v to the right of cursor position.
			-- Do not move cursor.

	merge_left (other: like Current)
			-- Merge other into current structure before cursor
			-- position. Do not move cursor. Empty other.

	merge_right (other: like Current)
			-- Merge other into current structure after cursor
			-- position. Do not move cursor. Empty other.
	
feature -- Removal

	remove
			-- Remove current item.
			-- Move cursor to right neighbor
			-- (or after if no right neighbor).

	remove_left
			-- Remove item to the left of cursor position.
			-- Do not move cursor.

	remove_right
			-- Remove item to the right of cursor position.
			-- Do not move cursor.

	wipe_out
			-- Remove all items.

	split (n: INTEGER_32)
			-- Remove from current list
			-- min (n, count - index - 1) items
			-- starting at cursor position.
			-- Move cursor right one position.
			-- Make extracted sublist accessible
			-- through attribute sublist.
		require
			not_off: not off
			valid_sublist: n >= 0

	remove_sublist
	
invariant
	non_empty_list_has_two_endpoints: not is_empty implies (first_element /= Void and last_element /= Void)
	empty_list_has_no_endpoints: is_empty implies last_element = Void
	first_element_constraint: attached first_element as f implies f.left = Void
	last_element_constraint: attached last_element as l implies l.right = Void

note
	copyright: "Copyright (c) 1984-2018, Eiffel Software and others"
	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
	source: "[
		Eiffel Software
		5949 Hollister Ave., Goleta, CA 93117 USA
		Telephone 805-685-1006, Fax 805-685-6869
		Website http://www.eiffel.com
		Customer support http://support.eiffel.com
	]"

end -- class TWO_WAY_LIST

Generated by ISE EiffelStudio