In my program, I have a bunch of growing arrays where a new element grows one by one to the end of the array. I defined lists as bottlenecks for speed in a critical state of my program due to their slow access time compared to an array - switching to an array significantly increased performance to an acceptable level. Therefore, to grow an array, I use Array.Resize. This works well, since my implementation limits the size of the array to about 20 elements, so O (N) Array.Resize's performance is limited.
But it would be better if there was a way to simply increase the array with one element at the end without using Array.Resize; which, I suppose, copies the old array to an array of a new size.
So my question is: is there a more efficient method of adding one element to the end of an array without using List or Array.Resize?
source
share