Linked List iterating over and inserting an element around (before/after) the current position.

Josh foo at bar.com
Sun May 19 22:20:48 UTC 2019


Thank you, that helps big time.

This is just more curiosity, but do you happen to know why I have 
to use DList.linearRemove() instead of DList.remove()?

import std.stdio;
import std.container.dlist;
import std.algorithm;
import std.range;

void main()
{
     auto list = make!DList("the", "quick", "brown", "fox");
     auto range = list[].find("quick").take(1);
     list.remove(range);
     list[].each!writeln; // the brown fox
}

This results in a compiler issue:

onlineapp.d(10): Error: function 
std.container.dlist.Container!string.DList.remove(Range r) is not 
callable using argument types (Take!(Range))
onlineapp.d(10):        cannot pass argument range of type 
Take!(Range) to parameter Range r

Changing "remove" to "linearRemove" fixes it, but both the remove 
and linearRemove functions take a Range object, and linearRemove 
seems to just be a pass through to remove.



More information about the Digitalmars-d-learn mailing list