【轉載】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等。

浙公網安備 33010602011771號