I’ve been searching for the standard implementation of a doubly linked list in c# (so that I have a linked list I can iterate over backwards) and cannot find one. I feel like something so simple must have an implementation that I’m just missing.
If it does exist, for which version of c#/.net does it exist?
Reverse iteration in general seems to be something not intended to be done in c#. Is my mind just stuck too much in c++/stl mode or is this something sorely lacking in c#?
I’m aware of LinkedList but in failing to find a way to iterate over it backwards had assumed it was singly linked.
If LinkedList is doubly linked how does one go about iterating over it backwards (Efficiently)?
As well as the answers given here, you can write an extension method to
LinkedList<T>to make it slightly easier to reuse:Use with: