Here's a rough equivalence:
Dictionary<K,V>
<=> hash_map<K,V>
HashSet<T>
<=> hash_set<T>
List<T>
<=> vector<T>
LinkedList<T>
<=> list<T>
The .NET BCL (base class library) does not have red-black trees (stl map) or priority queues (make_heap(), push_heap(), pop_heap()).
.NET collections don't use "iterators" the way C++ does. They all implement IEnumerable<T>
, and can be iterated over using the "foreach
statement". If you want to manually control iteration you can call "GetEnumerator()
" on the collection which will return an IEnumerator<T>
objet. IEnumerator<T>.MoveNext()
is roughly equivalent to "++" on a C++ iterator, and "Current" is roughly equivalent to the pointer-deference operator ("*").
C# does have a language feature called "iterators". They are not the same as "iterator objects" in the STL, however. Instead, they are a language feature that allows for automatic implementation of IEnumerable<T>
. See documentation for the yield return
and yield break
statements for more information.