Removing from SList (std.container)...
Steven Schveighoffer
schveiguy at yahoo.com
Wed Jun 27 13:14:53 PDT 2012
On Wed, 27 Jun 2012 15:57:42 -0400, Roman D. Boiko <rb at d-coding.com> wrote:
> On Wednesday, 27 June 2012 at 19:55:02 UTC, Roman D. Boiko wrote:
>>> Look up SList docs, even with a reference to a *specific element*, you
>>> cannot do O(1) removal.
>> Ha-ha, didn't know SList doesn't support that.
> I somehow confused removal after a referenced element (which should be
> easy to implement, but not very useful) with removal of that element
> (which is not possible in 0(1) in a singly-linked list.
Removal of that element is perfectly possible, you just need to maintain a
reference to its predecessor. Which SList's range does not keep track
of. It all depends on tradeoffs of what you want for performance, vs.
features. It's why I contend that generic singly linked list is difficult
to create. Can't please everyone.
And iterators are not necessary, ranges are quite possible.
-Steve
More information about the Digitalmars-d-learn
mailing list