removing element from DList
Jonathan M Davis
jmdavisProg at gmx.com
Mon Nov 5 10:47:09 PST 2012
On Monday, November 05, 2012 19:35:57 Jack Applegame wrote:
> On Monday, 5 November 2012 at 18:06:44 UTC, Michael wrote:
> > Something like
> >
> > auto r = list[$ - 1];
>
> Error: no [] operator overload for type DList!(int)
The range returned by list isn't random access, and it can't be random access,
so that won't work. Regardless, that would have given you the last element,
not a range over just the last element. It would have to be list[$ - 1 .. $]
to give you a range over just the last element, but that requires a sliceable
random-access range (which DList's range can't be). If all you want is the
last element, then use list[].back, since DList's range is bidirectional.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list