www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DList bug or programmer error?

reply "Daniel K" <danielk.misc gmail.com> writes:
This block of code fails the second assert, why? Using 
stableRemove{Front,Back} does not fix it.

----
import std.range;
import std.container;

unittest {
   auto dl2 = DList!int([2,7]);
   dl2.removeFront();
   //dl2.stableRemoveFront();
   assert(dl2[].walkLength == 1);
   dl2.removeBack();
   //dl2.stableRemoveBack();
   assert(dl2.empty, "not empty?!");
}


void main(){
}
----

rdmd -unittest file.d
Apr 12 2014
parent "monarch_dodra" <monarchdodra gmail.com> writes:
On Saturday, 12 April 2014 at 19:34:11 UTC, Daniel K wrote:
 This block of code fails the second assert, why?
Because DList is buggy. It should pass. I have an open pull that fixes this, FYI.
Apr 12 2014