Skip to main content
Code Review

Return to Answer

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

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 is AddLast
  • 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 is AddLast
  • 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 is AddLast
  • 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.

added 557 characters in body
Source Link
t3chb0t
  • 44.7k
  • 9
  • 84
  • 190

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 is AddLast
  • 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 is AddLast
  • 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.

Source Link
t3chb0t
  • 44.7k
  • 9
  • 84
  • 190

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.

lang-cs

AltStyle によって変換されたページ (->オリジナル) /