Feature Request: Linked Arrays

downs default_357-line at yahoo.de
Sat May 3 06:22:58 PDT 2008


Steven Schveighoffer wrote:
> If each array chunk is the same size, you could store the array in an array 
> of arrays.  Then lookup time becomes O(1), and appending data is not going 
> to cause a copy of the other array chunks that you already have allocated.
> 

Yeah but that just reduces the appending problem, not removes it.
Admittedly, this might be sufficient in many cases.

> If you add a huge piece that is bigger than one chunk, just allocate that 
> piece, then slice the piece up into chunks.
> 
> It could actually be an array of pointers, assuming all your chunks are the 
> same size.
> 
> I'd prefer that to a linked list of arrays, where traversal is O(n) (with a 
> small constant)

Um, excuse me but isn't traversal always O(n)?
Perhaps you meant lookup - keep in mind that my original proposal was not intended for situations where random lookup is important (queues, buffers and stacks).

> 
> -Steve 
> 
> 



More information about the Digitalmars-d mailing list