DList and SList missing length property?
monarch_dodra
monarchdodra at gmail.com
Tue May 28 14:18:31 PDT 2013
On Tuesday, 28 May 2013 at 19:24:05 UTC, Steven Schveighoffer
wrote:
> You know, it is trivial to have an O(1) splice O(n) length list
> wrapped into an o(n) splice O(1) length list. All you need is
> to add a tracked length. And this is a REAL pain when you have
> to do it manually. There should just be two list types in
> <list>
I think having two lists in list would be overkill.
I *do* find the standard's choice odd though: The *primary*
reason I ever use list, ever, is for its splice ability to move
elements without copying them, and still having their addresses
valid. No other container can do that.
I don't get why they borked list's primary strength for a
function you really shouldn't be using anyway. Worst, as you say,
it is easy to implement one in terms of the other... but not the
other way around. By doing what they just did, they effectively
closed *any* way to splice in 0(1)...
If you don't need splice, then most of the time, deque is a
better choice of a container, and *that* has 0(1) length (along
with a few neat properties).
All this really doesn't make sense to me.
More information about the Digitalmars-d
mailing list