[Gambas-devel] About List interface

Tobias Boege tobias at ...692...
Fri Aug 31 13:57:14 CEST 2012


On Thu, 30 Aug 2012, Tobias Boege wrote:
> Hi Benoit,
> 
> I think the current List class follows your suggestions but there are some
> critical points:
> 
> 1. Enumeration
> I use the List.Current as the enumeration pointer as this seems conclusive:
> 
> For Each List
> 	Print List.Current ' All items
> Next
> 
> This makes of course problems in nested loops with triggered BREAK. The
> current implementation works somewhat cruel internally (until I incorporate
> List.Take() into the enumeration state updating) that the user may not
> understand what is going on.
> 
> My question therefore: Should List.Current not be modified at all during
> For Each or should the limitations written down?
> 
> 2. Enumeration (2)
> >From where shall the enumeration start? From the beginning or the Current
> node?
> 
> 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?
> 
> Remarks
> I have the ususal test project and some benchmarks so far. Interestingly,
> the current implementation cannot beat Variant[] even in best cache locality
> order of operations... by a hair's breadth ;-)
> I'll continue with improving the List internally and looking for rbtrees.
> 
> Regards,
> Tobi
> 

4. Backwards enumeration
I'd like to enable the user to For Each backwards. What would that look
like? I thought of a property named Backwards which sets a bit in the List
to start the next enumeration as backwards and returns itself. It would
look like this then:

For Each List.Backwards
	Print List.Current ' All items backwards
Next

What do you think?





More information about the Devel mailing list