Let's say I'm in C#, I have a List<T>, I want to increase its length to N but I don't care what the new items are filled with or I just want them to be default(T). is there a sensible way to do this? Considering abusing AddRange() somehow.
-
-
-
Replying to @viiviicat @mcclure111
If the list is gonna be really big, try setting the Capacity property to the value you want first, then adding using a for loop? That way you won't reallocate in the loop.
1 reply 0 retweets 1 like -
Replying to @mcclure111 @viiviicat
yeah that gets you a fill with default(T) with only one malloc where AddRange() is gonna be two at minimum
11:24 AM - 18 Jul 2018
0 replies
0 retweets
0 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.