Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Appendix B. Migration Cheat Sheet

Appendix B. Migration Cheat Sheet

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>  



  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial