foreword to cursors |
indexing title: "The project-wide universal properties: facilities for% %being traversable in one direction - towards the last entry" deferred class interface SIMPLE_TRAVERSABLE_ feature -- Operations cursor: SIMPLE_CURSOR__ -- delivers a new cursor to the beginning of the container feature -- Queries is_inside (cs: like cursor): BOOLEAN -- is this cursor traversing the container ? require valid_argument: cs /= Void is_protected: BOOLEAN -- True if at least one cursor is traversing the container; -- otherwise - False feature {SIMPLE_CURSOR_} first (cs: SIMPLE_CURSOR_) -- positions on the first item require proper_cursor: is_inside (cs) deferred forth (cs: SIMPLE_CURSOR_) -- moves one item forward require proper_cursor: is_inside (cs) deferred end
index |
contents |
structure |
indexing title: "The project-wide universal properties: facilities for% %being traversable in the both directions" deferred class interface TRAVERSABLE_ inherit SIMPLE_TRAVERSABLE_ redefine cursor feature -- Operations cursor: CURSOR_ -- delivers a new cursor to the beginning of the container feature {CURSOR_} back (cs: CURSOR_) -- moves one item backwards require proper_cursor: is_inside (cs) deferred last (cs: CURSOR_) -- positions on the last item require proper_cursor: is_inside (cs) deferred end
Each cursor is tied to exactly one container. We have two types of cursors - one starts at the beginning and stops at the end and the other can work in the both directions (we will not discuss here what 'beginning' and 'end' means). See also the chapter about iterators which gives a different possibility to do something with the content of a list or table.
index |
contents |
structure |
indexing title: "Simple cursors: tools for traversing all the ancestors% %of class SIMPLE_TRAVERSABLE_" class interface SIMPLE_CURSOR_ creation {SIMPLE_TRAVERSABLE_} make feature -- Operations first -- positions on the first item forth -- moves one item forward require still_inside: not is_finished stop -- stops traversal feature -- Queries is_finished: BOOLEAN -- is the end of the structure reached ? target: SIMPLE_TRAVERSABLE_ -- the structure the cursor belongs to end
index |
contents |
structure |
indexing title: "Cursors: tools for traversing all the ancestors% %of class TRAVERSABLE_"; class interface CURSOR_ inherit SIMPLE_CURSOR_ redefine target creation {TRAVERSABLE_} make feature -- Operations back -- moves one item backwards require still_inside: not is_finished last -- positions on the last item feature -- Queries target: TRAVERSABLE_ -- the structure the cursor belongs to end