What is the analogous class of C++ std::vector
in C#?
I want a class where it keeps an internal array inside and supports insertion at the back in O(1)
time.
Here is a list with some C++
/ C#
containers that are roughly equivalent (not exact replacements) to each other:
std::multiset
-> SortedDictionary<Tkey, int>
(int
keeping count of the number of Tkey
s)
List<T>
nor vector
are O(1) for all insertions (only those that happen at index == count
, and if a resize occurs this wouldn't be the case either).
std::list is backed by array, each deletion would incur memory copy, same behavior as C# List. while C# LinkedList is backed by node list, same as std::vector.
so I believe below is correct.
std::vector
in C#.