List.RemoveAt(int index) returns void??
List.RemoveAt(int index) returns void??
Would it have really hurt to return the value that is being removed I mean, if you don't need it then just don't capture the return value. If I want to drain a list from the head then I have to write goofy code like this:
| |
List<int> primes = new List<int>(); int nextPrime = candidates[0]; candidates.RemoveAt(0); primes.Add(nextPrime);
|
this was what I was expecting to be able to do:
| |
List<int> primes = new List<int>(); int nextPrime = candidates.RemoveAt(0); primes.Add(nextPrime);
|
List.RemoveAt(int index) returns void??
DavidLSNB
sxsoptic
List is backed by an array, and RemoveAt(0) just does a memory block move of the array values 1...n down to position 0 when you remove the first element. The first element is never read from memory.
So yes, it would actually hurt performance (a little tiny bit, depending on page boundaries and cache contents...) to add this functionality.
rwike