Why is LinkedList lacking so much?

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I just realized that I need elements in my List<> to be doubly linked. So I
searched for "C# Linked List" and found the LinkedList<> class. I was happy
until I looked at the docs for this class and realized that it's missing so
much. For example, Find(predicate), operator[], etc

Is there a reason for this other than MS didn't have time to add some of the
nice stuff from list<> to LinkedList<> or am I missing something?

I will just handle the links myself by changing my class to have a previous
and next reference, but what a shame.
 
Steve,

You could always use a List<T> in a linked list. Granted, the
performance profiles are different for certain operations, but if it suits
your needs, and the performance is acceptable, then by all means, use a
List.

You might also find some open source implementations of a doubly linked
list out there as well.
 
Thanks Nicholas,

I guess I was just mostly confused why LinkedList<> didn't have operator[]
as this would make my change from a List<> to a LinkedList<> quite involved.

I will check out CodeProject and see what they have ;)
Have a good weekend,
Steve

Nicholas Paldino said:
Steve,

You could always use a List<T> in a linked list. Granted, the
performance profiles are different for certain operations, but if it suits
your needs, and the performance is acceptable, then by all means, use a
List.

You might also find some open source implementations of a doubly linked
list out there as well.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Steve said:
I just realized that I need elements in my List<> to be doubly linked. So
I searched for "C# Linked List" and found the LinkedList<> class. I was
happy until I looked at the docs for this class and realized that it's
missing so much. For example, Find(predicate), operator[], etc

Is there a reason for this other than MS didn't have time to add some of
the nice stuff from list<> to LinkedList<> or am I missing something?

I will just handle the links myself by changing my class to have a
previous and next reference, but what a shame.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top