Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is a List in C# equal to that of an ArrayList in terms of time complexity?
As it is my understanding that they're both similar in how they function, being dynamic arrays?
Both ArrayList and List<T> have the same basic implementation, using an array to store the items, reallocating as necessary when items are added. Indeed, much of List<T> is simply copy/paste from ArrayList, with appropriate changes to support the generics.
While there may be small differences in actual performance, the "big-O" complexity of operations in each would be the same.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
So I am making an inventory system and I have a choice to make inventory through lists and arrays. Which approach is better and why in C#? This inventory system is for a 2d Platformer in unity.
In .Net, a list is a wrap of an array. It has similar performance, but List has built-in methods to resize the array, which contains all entries of the list. If your arrays are never resized, not need to use List.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I trying to find some information about the 'Expression-bodied members' - to know if using the 'Expression-bodied members' ( beside simple properties or method ) improve some performance of the application
( maybe after compile the Expression-bodied members is call as inline method and this can improve some performance ( just an option ) )
but i can't find any explain to this.
anyone know if using the Expression-bodied members is just for better code or it also make some better performance ?
Very often it is used just to write shorter (thus writting code faster?) and more readable code.
But trying to force => whenever you can may have negative effect on readability of yours code.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How hashset memory overhead depends on objects size? And what if objects have different size?
The size of the HashSet is going to be related to the size of a variable of the type of objects that the HashSet holds. So for all reference types, that's the size of a reference, regardless of which type it is.
And what if objects have different size?
A HashSet can only store objects of one type, so they can't have a different size. They must all be the same size.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Someone can explain how Collections.Concurrent library are work ?
How we get the thread-safe ?
Is their performance are good ?
You can inspect the concurrent collections implementation by yourself here (this is for ConcurrentDictionary<TKey,TValue>, other collections you can find using the left navigation pane) and get the exact picture of how they work.
The implementation depends on the collection type. It uses volatile, SpinWait, Interlocked and lock.
More information about performance is available in this paper.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
What is the time complexity of the method String.GetHashCode()? For example, if hashed string of length n, by mod 2 using Horner's scheme it's O(n).
What is Big O for GetHashCode?
According to the reference source the time complexity is O(n). It basically just takes each character of the string and adds its value to the hash.
As mentioned in Peter Ritchie's comment the algorithm can be changed by using the <UseRandomizedStringHashAlgorithm> element.