【转载】C++标准库容器与C#容器对比

转载自栈他喵的又溢出了

我简单的整理一下,方便观看:

C#容器 C++容器 备注
Array C array .net的Array可以是非0起始索引(鸡肋?查了一下,用Array.CreateInstance实现)
List std::vector
Dictionary<TKey, TValue> unordered_map<Key, Data>
HashSet unordered_set
SortedDictionary<TKey, TValue> std::map<Key, Data>
SortedList<TKey, TValue> std::vector 相当于std::vector,只是添加元素是利用二分查找来保持排序的
SortedSet std::set
Queue std::queue
Stack std::stack
LinkedList std::list

.net这边缺少C++中“multi-”相关的容器,但是又添加了一些线程安全的容器(“Concurrent-”开头),如ConcurrentDictionary,ConcurrentQueue等。

posted @ 2022-04-13 13:49  薛定谔の三味  阅读(87)  评论(0编辑  收藏  举报