note description: "Sequential, one-way linked lists" library: "Free implementation of ELKS library" legal: "See notice at end of class." status: "See notice at end of class." names: linked_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 LINKED_LIST [G] create make, make_from_iterable feature -- Access item: G -- Current item first: like item -- Item at first position last: like item -- Item at last position index: INTEGER_32 -- Index of current position cursor: LINKED_LIST_CURSOR [G] -- Current cursor position feature -- Access: Cursor new_cursor: LINKED_LIST_ITERATION_CURSOR [G] -- Fresh cursor associated with current structure feature -- Measurement count: INTEGER_32 -- Number of items feature -- Status report readable: BOOLEAN -- Is there a current item that may be read? after: BOOLEAN -- Is there no valid cursor position to the right of cursor? before: BOOLEAN -- Is there no valid cursor position to the left of cursor? off: BOOLEAN -- Is there no current item? isfirst: BOOLEAN -- Is cursor at first position? islast: BOOLEAN -- Is cursor at last position? valid_cursor (p: CURSOR): BOOLEAN -- Can the cursor be moved to position p? Full: BOOLEAN = False -- Is structured filled to capacity? (Answer: no.) is_inserted (v: G): BOOLEAN -- Has v been inserted at the end by the most recent put or -- extend? feature -- Cursor movement start -- Move cursor to first position. ensure then empty_convention: is_empty implies after finish -- Move cursor to last position. -- (Go before if empty) ensure then empty_convention: is_empty implies before forth -- Move cursor to next position. back -- Move to previous item. move (i: INTEGER_32) -- Move cursor i positions. The cursor -- may end up off if the offset is too big. ensure then moved_if_inbounds: ((old index + i) >= 0 and (old index + i) <= (count + 1)) implies index = (old index + i) before_set: (old index + i) <= 0 implies before after_set: (old index + i) >= (count + 1) implies after go_i_th (i: INTEGER_32) -- Move cursor to i-th position. go_to (p: CURSOR) -- Move cursor to position p. 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. ensure then previous_exists: previous /= Void item_inserted: attached previous as q and then q.item = v put_right (v: like item) -- Add v to the right of cursor position. -- Do not move cursor. ensure then next_exists: next /= Void item_inserted: not old before implies (attached next as n and then n.item = v) item_inserted_before: old before implies (attached active as c and then c.item = v) replace (v: like item) -- Replace current item by v. 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. feature -- Duplication copy (other: like Current) -- Update current object using fields of object attached -- to other, so as to yield equal objects. invariant prunable: prunable empty_constraint: is_empty implies ((first_element = Void) and (active = Void)) not_void_unless_empty: (active = Void) implies is_empty before_constraint: before implies (active = first_element) after_constraint: after implies (active = last_element) 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 LINKED_LIST
Generated by ISE EiffelStudio