[Gambas-devel] About List interface

Tobias Boege tobias at ...692...
Sun Sep 2 20:04:25 CEST 2012


> > 3. Prepend and the first Current
> > When the first element is added to the List, it automatically gets Current.
> > Before, there is none. If afterwards another element gets Prepend()'d,
> > Current is the second node without the user doing anything on Current. Is
> > this logical enough?
> 
> You can choose to make the last inserted element current, whatever the 
> insertion method was.
> 
> Regards,
> 
> -- 
> Beno?t Minisini

Hmm, having considered this issue a bit further, I would rather leave the
Current invalid until the user sets it. If it is invalid, MoveNext() is the
same as MoveFirst() and MovePrev() is the same as MoveLast() but accessing
List.Current gives error.

The reason for which I didn't choose changing on insertion is that it could
get cumbersome for the user to save Current before every insertion if they
don't want it to change.

Last alternative could be using a flag. This is set whenever the user
explicitly sets Current; before, it is cleared. If the bit is set, Current
always remains the same, if it is cleared, any insertion moves Current to
the first node. This sounds like the best solution to me...

What do you think, finally?

Regards,
Tobi





More information about the Devel mailing list