Bug 12913 – Mistake concerning DLists

Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-13T15:26:00Z
Last change time
2014-08-21T04:32:11Z
Keywords
pull
Assigned to
nobody
Creator
steffen.wolf

Comments

Comment #0 by steffen.wolf — 2014-06-13T15:26:25Z
Hi, I don't know if this is known already - I didn't find a similar bug - but either there's a mistake in the documentation or in the current compiler version (DMD 2.065.0 on Windows 7 x64). The Library documentation for std.container says this concerning DLists: insert is an alias of insertBack, and therefore "Inserts stuff to the back of the container." removeAny "Picks one value from the front of the container, removes it from the container, and returns it." In a recent project, I used insert and removeAny in conjunction to get a queue-like behaviour. Instead, when I tested the code, it behaved like a stack. Therefore, as far as I can tell, either insert has to be an alias of insertFront or removeAny takes elements from the back of the DList.
Comment #1 by safety0ff.bugz — 2014-06-13T15:42:31Z
Comment #2 by sigod.mail — 2014-07-03T19:26:55Z
Comment #3 by monarchdodra — 2014-07-03T19:46:23Z
If you need to have a specific stack/queue, you should really be using the insertFront/insertBack and removeFront/removeBack functions. "insert" and "removeAny" are meant as "implementation defined", and actual behavior can vary from container to container.
Comment #4 by sigod.mail — 2014-08-18T18:39:11Z
Comment #5 by sigod.mail — 2014-08-20T08:44:51Z
Comment #6 by github-bugzilla — 2014-08-21T04:32:10Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/e881d153ac3b0cfe18f92f36e7779fcaede3abd3 Fix Issue 12913 - container: removeAny: fix docs (position of removed element must be unspecified) https://github.com/D-Programming-Language/phobos/commit/a3119548b89a3b409c824a93427391570d4ddefb Merge pull request #2443 from sigod/removeany-docs Fix Issue 12913 - container: removeAny: fix docs