比较C ++ STL集合和C#集合? [英] Comparison of C++ STL collections and C# collections?
问题描述
我仍在学习C#,很惊讶地发现 List< T>
更像是 std :: vector
而不是 std:: list
.有人可以用STL来描述所有C#集合吗(或者如果STL比较比较困难,可以使用带有Wikipedia链接的标准概念数据类型?我希望该参考将非常有用.
I'm still learning C# and was surprised to find out that a List<T>
is much more like a std::vector
than a std::list
. Can someone describe all the C# collections in terms of the STL (or if STL comparisons are difficult, standard conceptual data types with Wikipedia links? I expect the reference would be widely useful.
感兴趣的收藏集的最低清单包括(随意添加其他收藏集):
A minimal list of collections of interest include (feel free to add others):
- 数组
- 列表
- ArrayList
- 哈希表
- 字典
- ListDictionary
- SortedDictionary
- 排序列表
- 排队
- 堆栈
我刚刚发现了一个可能有趣的类似问题:映射在stl C ++和C#容器之间
I just found this similar question that may be of interest: Mapping between stl C++ and C# containers
推荐答案
这就是我发现的内容(忽略了旧的非通用集合):
Here's what I've found (ignoring the old non-generic collections):
-
Array
-C数组,尽管.NET Array 可以具有一个非零的起始索引. -
List< T>
-std :: vector< T>
-
Dictionary< TKey,TValue>
-unordered_map<密钥,数据> 代码>
-
HashSet< T>
-unordered_set< Key>
-
SortedDictionary< TKey,TValue>
-std :: map< Key,Data>
-
SortedList< TKey,TValue>
-等同于std :: vector< T>
,但在添加元素时通过使用二进制搜索+插入将其保持有序. -
SortedSet< T>
-std :: set< Key>
-
Queue< T>
-std :: queue< T>
-
Stack< T>
-std :: stack< T>
-
LinkedList< T>
-std :: list< T>
Array
- C array, though the .NET Array can have a non-zero starting index.List<T>
-std::vector<T>
Dictionary<TKey, TValue>
-unordered_map<Key, Data>
HashSet<T>
-unordered_set<Key>
SortedDictionary<TKey, TValue>
-std::map<Key, Data>
SortedList<TKey, TValue>
- equivalent to astd::vector<T>
but keeping it ordered by using binary search + insert when adding elements.SortedSet<T>
-std::set<Key>
Queue<T>
-std::queue<T>
Stack<T>
-std::stack<T>
LinkedList<T>
-std::list<T>
.NET集合中明显缺少的是"multi-"变体,例如,code> multiset , multimap
等.但是,他们添加了许多非常有用的线程安全集合:"Concurrent-"变体,例如 ConcurrentQueue
等.
Notably missing from the .NET collections are the "multi-" variants, e.g., multiset
, multimap
, etc. However, they have added a number of very useful threadsafe collections: the "Concurrent-" variants, e.g., ConcurrentDictionary
, ConcurrentQueue
, etc.
这篇关于比较C ++ STL集合和C#集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!