removing element from DList

Tobias Pankrath lists at pankrath.net
Mon Nov 5 11:12:55 PST 2012


On 05.11.2012 17:41, Jack Applegame wrote:
> How to get range for single just inserted element?
>
> DList!int list;
> ...
> list.insertBack(5);
> auto r = ??? // get range for single last element
> ...
> list.insertBack(something);
> ...
> list.remove(r);

There is no way to do that in constant time with current dlist 
interface. (You could do something like 
list[].drop(walkLength(list)-1).takeOne), which is embarrassing.

I think DList should offer a native backwards range, so that you can do 
list.retro.takeOne.


More information about the Digitalmars-d-learn mailing list