Does anyone know of a good overview of the different C# collection types? I am looking for something showing which basic operations such as Add
, Remove
, RemoveLast
etc. are supported, and giving the relative performance.
It would be particularly interesting for the various generic classes - and even better if it showed eg. if there is a difference in performance between a List<T>
where T
is a class and one where T
is a struct.
A start would be a nice cheat-sheet for the abstract data structures, comparing Linked Lists, Hash Tables etc. etc. Thanks!
A structure is a collection of one or more variables, possibly of different types, grouped under a single name. It is a user-defined data type.
If both operands have the same type, then no further conversion is needed. Otherwise, if both operands have signed integer types or both have unsigned integer types, the operand with the type of lesser integer conversion rank is converted to the type of the operand with greater rank.
Most of the time, for small programs, we use the basic fundamental data types in C – int, char, float, and double. For more complex and huge amounts of data, we use derived types – array, structure, union, and pointer. Enumeration and void consist of enum and void, respectively.
The C language provides the four basic arithmetic type specifiers char, int, float and double, and the modifiers signed, unsigned, short, and long. The following table lists the permissible combinations in specifying a large set of storage size-specific declarations.
The following content was originally taken from MSDN http://xbox.create.msdn.com/downloads/?id=123&filename=DataStructures_CheatSheet.doc (but the link has since died).
As in the image above, the content was originally provided as a table (which StackOverflow doesn't support).
Given an image isn't easily indexed below is a somewhat crude programmatic conversion of the information to lists:
O(n)
O(n)
O(n)
O(n)
O(1)
O(1)
O(n)
best case O(1); worst case O(n)
O(1)
O(n)
O(n)
O(1)
O(1)
O(n)
best case O(1); worst case O(n)
O(1)
O(n)
O(n)
O(1)
O(1)
O(n)
O(1)
O(1)
O(1)
O(1)
O(n)
O(1)
O(n)
best case O(1); worst case O(n)
O(1)
N/A
N/A
N/A
N/A
N/A
best case O(1); worst case O(n)
O(1)
N/A
N/A
N/A
N/A
N/A
best case O(1); worst case O(n)
O(1)
best case O(1); worst case O(n)
O(1)
O(1)*
O(1)*
O(1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With