xxxxxxxxxx
import std;
struct MyType
{
int id;
// [...] other stuff
}
void main()
{
auto list = DList!MyType();
// Fill the list.
foreach (i; 0 .. 10)
list.insertBack(MyType(i));
// Traverse the list, conditionally remove one element.
for (auto range = list[]; !range.empty;)
if (range.front.id == 3)
list.popFirstOf(range);
else
range.popFront();
// Traverse the list, conditionally insert one element.
for (auto range = list[]; !range.empty;)
{
if (range.front.id == 6)
list.insertBefore(range, MyType(66));
range.popFront();
}
// Print modified list.
foreach (e; list)
writeln(e);
}