Re: Backward iterators

Eric Bezault <[email protected]> Sat, 01 Nov 2008 20:33:21 +0100
Newsgroups gmane.comp.lang.eiffel.gobo.devel
Message-ID <[email protected]>
Colin Paul Adams wrote:
>>>>>> "Eric" == Eric Bezault <[email protected]> writes:
> 
>     Eric> I thought about that as well. I think that I was the first
>     Eric> one to explicitly state in the header comments that the
>     Eric> iterators are traversing from first to last. Which of course
>     Eric> raises the issue that we miss the iterators from last to
>     Eric> first. We also probably miss a few other possible iterators
> 
> There is a class in EiffelBase, called something like LINEAR_ITERATOR
> that has a whole lot of variants. It might be worth taking a look at
> (but with caution - when I last looked at it, it was a real mess - at
> least as far as contracts went. i raised the issue with Manu, and they
> did something about it, but i haven't looked at it to see what0.
> 
>     Eric> such as do_until.  Any naming convention for the backward
>     Eric> iterator feature names?
> 
> *_backwards seems straight-forward.

My dictionary says that Americans use "backward" instead
of "backwards".

> E.g do_all_backwards, do_if_backwards and do_all_with_index_backwards
> all read ok.
> 
> It would be more compact to drop the all, but then we get an
> inconsistent pattern:
> 
> do_backwards, do_if_backwards, do_backwards_with_index.
> 
> Still, I think I prefer these shorter names.
> If we were starting from scratch, I would definitely go for this,
> along with fo_forwards, etc., rather than do_all.

We could have the forward(s) and backward(s) versions,
and have `do_all' use one or the other (when people
don't care about the direction of the traversal). For
example in DS_CONTAINER we have `do_all' since we don't
really know or care about traversal directions. In
class DS_LINEAR it could be implemented using
`do_forward(s)'.

-- 
Eric Bezault
mailto:[email protected]
http://www.gobosoft.com

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/