Search code examples
c#c++listpointersvector

Is a C# list like a C++ list?


Im just wondering if a C# List is like a C++ List.

Removing an element in the middle of a big list in C++ is fast because i know the elements are just pointing to the next.

So when removing a element in the middle of a big C# list, is that the same as in C++? Or is the C# list more like a C++ vector with indexes because you can get the index number of the elements in the C# list.


Solution

    • C# List<T> is analogous to, and has the same performance characteristics, as C++ std::vector<T>.
    • C# LinkedList<T> is analagous to, and has the same performance characteristics, as C++ std::list<T>.

    The performance characteristics are discussed in some detail in the remarks sections of the relevant sections of the .NET documentation: List<T>, LinkedList<T>.