I fail to see why the Array.Copy or other slow method in the initial insert
example is of any relevance as the initial question was:
Insert an integer value (so not a list of values) into a sorted array.
If the question would have been: insert an array of integer values into a
sorted array, it might have been better to write QSort
out, and start somewhere in the middle of the algorithm, instead of keeping
unused array space just to avoid re-allocation.
FB
> Okay... I definately see what you mean...just for the sake of
> the archives, here is my new class with some performance
> numbers. I've added the test method down at the bottom for reference.
>
> new method (in milliseconds)
> 0 10,000 calls to List.Insert()
> 0 15,000 calls to List.Insert()
> 0 20,000 calls to List.Insert()
> 15.625 50,000 calls to List.Insert()
> 15.625 75,000 calls to List.Insert()
> 15.625 100,000 calls to List.Insert()
>
> old method (in milliseconds)
> 203.125 10,000 calls to List.Insert()
> 265.625 15,000 calls to List.Insert()
> 1062.5 25,000 calls to List.Insert()
> 6687.5 50,000 calls to List.Insert()
> 18296.875 75,000 calls to List.Insert()
> 35468.75 100,000 calls to List.Insert()
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com