Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
STL to Generics
| STL | .NET Generics class | Comments |
|---|---|---|
| vector | List<T> | |
| deque | LinkedList<T> | deque allows addition and deletion at both ends in constant time. |
| list | LinkedList<T> | list also allows addition and deletion at both ends in constant time. Thus, that is what is best mapped to these two containers. |
| stack | Stack<T> | |
| Queue | Queue<T> | |
| priority_queue | Not available | You can use PriorityQueue<TKey,TValue> described in Chapter 3, Dictionaries. |
| set | HashSet<T>, SortedSet<T> | Use SortedSet<T> if you always want the set to be sorted. |
| multiset | Not available. You can use OrderedBag from PowerCollections. | Can be modeled as Dictionary<T,int> or SortedDictionary<T,int> if you want entries to be sorted. |
| map | Dictionary<TKey,TValue> SortedDictionary<TKey,TValue> | Use SortedDictionary<TKey,TValue> if you always want entries to be sorted. |
| multimap | Dictionary<TKey,List<TValue>> | You can also use OrderedBag in PowerCollection |
| bitset | List<bool> |