Suggestion: dynamic array operations
Steve Horne
stephenwantshornenospam100 at aol.com
Thu Sep 7 22:19:23 PDT 2006
On Thu, 07 Sep 2006 11:19:12 -0400, nobody <nobody at mailinator.com>
wrote:
>So what sort of silly stuff would you write about possible benefits derived from
>having a list data structure built into the language?
There's already a built-in type for the links. It's called 'pointers'
;-)
There's just too many ways to do a linked list. Singly linked. Doubly
linked. Circular or with a clear start and end. Do you want separate
whole-list and iterator classes, or do you want to package the two in
a single class (as with a stack).
Bidirection lists implemented with a single link per item are fairly
cool, even though the iterators are a bit of a pain - each link is the
XOR of the previous and next item addresses, and the iterator needs
two adjacent item addresses. Needs a custom allocator to get the
benefit, but still good for listing very small items.
Picked it up from a website by an ex-Microsoft employee, IIRC. He used
address differences for the links, but XOR is a tad easier IMO.
A small set of built-in complex types is good, but libraries and
templates exist for a reason. If a standard library list type gets
really heavy use, it can always be absorbed into the language later.
Mind you, I guess a complex list-type specification might have
benefits along the lines of...
list!(item-type, link-style, separate-iterators-flag, ...)
But templates can do that. And anyway, lists are naff! I like trees!
--
Remove 'wants' and 'nospam' from e-mail.
More information about the Digitalmars-d
mailing list