I'd like to quickly point to one huge problem with the current implementation.
Your linked list uses extensively the NodeAt
method which is O(n). The AddLast
in the original implementation is however O(1). This could be a real bottle neck.
In a comment comment you say that:
The System.Collections.Generic.LinkedList misses some methods i'm used to work with, like Add Sort or access by index mylist[0]
- The LinkeList's
Add
method isAddLast
- You can sort the items with
OrderBy
- You can access elements by index with
ElementAt
(and it would be as fast or rather as slow as your implementation)
For example:
var foo = new LinkedList<string>(new[] { "z", "b", "a", "c" });
var fooSorted = new LinkedList<string>(foo.OrderBy(x => x));
var nthFoo = foo.ElementAt(2);
The sorting and returning a new linked list could be an extension too.
I'd like to quickly point to one huge problem with the current implementation.
Your linked list uses extensively the NodeAt
method which is O(n). The AddLast
in the original implementation is however O(1). This could be a real bottle neck.
In a comment you say that:
The System.Collections.Generic.LinkedList misses some methods i'm used to work with, like Add Sort or access by index mylist[0]
- The LinkeList's
Add
method isAddLast
- You can sort the items with
OrderBy
- You can access elements by index with
ElementAt
(and it would be as fast or rather as slow as your implementation)
For example:
var foo = new LinkedList<string>(new[] { "z", "b", "a", "c" });
var fooSorted = new LinkedList<string>(foo.OrderBy(x => x));
var nthFoo = foo.ElementAt(2);
The sorting and returning a new linked list could be an extension too.
I'd like to quickly point to one huge problem with the current implementation.
Your linked list uses extensively the NodeAt
method which is O(n). The AddLast
in the original implementation is however O(1). This could be a real bottle neck.
In a comment you say that:
The System.Collections.Generic.LinkedList misses some methods i'm used to work with, like Add Sort or access by index mylist[0]
- The LinkeList's
Add
method isAddLast
- You can sort the items with
OrderBy
- You can access elements by index with
ElementAt
(and it would be as fast or rather as slow as your implementation)
For example:
var foo = new LinkedList<string>(new[] { "z", "b", "a", "c" });
var fooSorted = new LinkedList<string>(foo.OrderBy(x => x));
var nthFoo = foo.ElementAt(2);
The sorting and returning a new linked list could be an extension too.
I'd like to quickly point to one huge problem with the current implementation.
Your linked list uses extensively the NodeAt
method which is O(n). The AddLast
in the original implementation is however O(1). This could be a real bottle neck.
In a comment you say that:
The System.Collections.Generic.LinkedList misses some methods i'm used to work with, like Add Sort or access by index mylist[0]
- The LinkeList's
Add
method isAddLast
- You can sort the items with
OrderBy
- You can access elements by index with
ElementAt
(and it would be as fast or rather as slow as your implementation)
For example:
var foo = new LinkedList<string>(new[] { "z", "b", "a", "c" });
var fooSorted = new LinkedList<string>(foo.OrderBy(x => x));
var nthFoo = foo.ElementAt(2);
The sorting and returning a new linked list could be an extension too.
I'd like to quickly point to one huge problem with the current implementation.
Your linked list uses extensively the NodeAt
method which is O(n). The AddLast
in the original implementation is however O(1). This could be a real bottle neck.
I'd like to quickly point to one huge problem with the current implementation.
Your linked list uses extensively the NodeAt
method which is O(n). The AddLast
in the original implementation is however O(1). This could be a real bottle neck.
In a comment you say that:
The System.Collections.Generic.LinkedList misses some methods i'm used to work with, like Add Sort or access by index mylist[0]
- The LinkeList's
Add
method isAddLast
- You can sort the items with
OrderBy
- You can access elements by index with
ElementAt
(and it would be as fast or rather as slow as your implementation)
For example:
var foo = new LinkedList<string>(new[] { "z", "b", "a", "c" });
var fooSorted = new LinkedList<string>(foo.OrderBy(x => x));
var nthFoo = foo.ElementAt(2);
The sorting and returning a new linked list could be an extension too.