Documentation of DList in std.container seems to be inaccurate

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 19 07:43:23 PST 2014


On Wed, Nov 19, 2014 at 08:18:55AM +0000, Koz Ross via Digitalmars-d wrote:
> I just spent a good while debugging something which arose as a result
> of the documentation of the DList's removeAny function. More
> precisely, it seems that removeAny removes from the *back*, rather
> than the front, as the documentation would indicate. To quote the
> relevant page (http://dlang.org/phobos/std_container.html#.DList):
[...]

The documentation was wrong before, but the whole point of removeAny()
is that it removes *any* element from the container, and it's not
specified *which* one is removed. The fact that a particular element
(front or back or whatever) is what happens to be removed from a
specific container, is something that user code should not rely on. The
idea is that you just want *one* element from the container, and it
doesn't matter which, so the container is free to choose the easiest one
to remove. The fact that the documentation then refers specifically to
front or back is a bug; user code was not supposed to rely on this.

I'm pretty sure the PR that fixes this problem has been checked in, but
I'm not sure why dlang.org hasn't been updated yet? Or has it only been
updated in the phobos-prerelease section?


T

-- 
Не дорог подарок, дорога любовь.


More information about the Digitalmars-d mailing list