c# equivalent for c++ vector or deque

半城伤御伤魂 提交于 2019-12-03 22:16:18
Matthew Watson

There's no built-in Deque container, but there are several implementations available.

Here's a good one from Stephen Cleary. This provides O(1) operations to index and also to insert at the beginning and append at the end.

The C# equivalent to Vector is List<T>. Indexed access is O(1), but insertion or removal is O(N) (other than Inserting at the end, which is O(1)).

Dale Wick

For a C# vector, a good candidate is System.Collection.Generic.List as others mentioned.
The closest to the deque in C++ would be System.Collection.Generic.LinkedList which is a doubly linked list.

Consider System.Collections.Generic.List and other from System.Collection.Generic they serve the same purpose as their C++ equivalents.
Additionally, there might be more containers for you. Look here.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!