C#集合u
List<T> 列表(動態數組),相當于C++的 vector
Queue<T> 隊列,先進先出
Stack<T> 棧,先進后出
LinkedList<T> 雙向鏈表,相當于C++中的list
SortedList<Tkey, TValue> 有序列表,相當于C++中的map
Dictionary<TKey, TValue> 字典,相當于C++中的 unordered_map
LookUp<TKey, TElement> 復合數據結構,一個鍵對應一個列表,相當于C++中的 std::unordered_map<T, std::vector<T>>
SortedDictionary<TKey, TValue> 有序字典,相當于C++中的 map
HashSet<T> 不重復的無序列表
SortedSet<T> 不重復的有序列表
BitArray
BitVector32
ImmutableArray<T> 不變的集合
多個并發集合 略
Hashtable
?
?
非泛型集合:
Hashtable 每個元素都是一個存儲在?DictionaryEntry?對象中的鍵/值對,其中鍵和值的類型可以是任意類型,通過 Add 方法添加鍵值對時,如果鍵已存在,則會拋出?System.ArgumentException?異常。
using System; using System.Collections;class Pet {public Pet(int id) { this.id = id; }public int id; } class Program {static void Main(string[] args){Hashtable ht = new Hashtable();ht.Add("1", 1);ht.Add(1, "1");ht.Add(3.14, "3.14");//ht.Add("1", "a"); //拋出 System.ArgumentException 異常Pet pet = new Pet(3);ht.Add(pet, "1");foreach (DictionaryEntry item in ht){Console.WriteLine(item.Key);}} }?HashTable數據結構存在問題:空間利用率偏低、受填充因子影響大、擴容時所有的數據需要重新進行散列計算。雖然Hash具有O(1)的數據檢索效率,但它空間開銷卻通常很大,是以空間換取時間。所以Hashtable適用于讀取操作頻繁,寫入操作很少的操作類型。
http://www.cnblogs.com/moozi/archive/2010/05/23/1741980.html
轉載于:https://www.cnblogs.com/tianyajuanke/p/4926382.html
總結
- 上一篇: 【js与jquery】三级联动菜单的制作
- 下一篇: 靠人不如靠自己啊