[C #] Lookup collection class ordered dictionary SortedDictionary <TKey, TValue> set

Dictionary <TKey, TValue> class supports a key value for each key, Lookup <TKey, TElement> class is similar to the Dictionary <TKey, TValue> class, but the key is mapped to a set of values , the assembly in this class System. Core implemented

Using System.Linq namespace definition.

Lookup <TKey, TElement> class can not create that as a general dictionary, but you must call ToLookup () method, which returns a Lookup <TKey, TElement> object. ToLookup () method is an extension method that can be used to implement IEnumerable <T> all class interface. As long as there is realization IEnumerable <T> can call this ToLookup () method of the interface.

This method requires a Func <TSource, TKey> type delegate, the delegate defines the selector key.

 Ordered dictionary

 SortedDictionary <TKey, TValue> is a binary search tree, wherein the key elements sorted.

The key type must implement IComparable <Tkey> interface. If the type of bond can not be sorted, you can also

Create an implementation of IComparer <TKey> interface of the comparator, the comparator is used as a parameter configuration war ordered dictionary function.

  SortedDictionary <TKey, TValue> and SortedList <TKey, TValue> similar functions.

However SortedList <TKey, TValue> is implemented as a list-based array, and SortedDictionary <TKey, TValue>

Class is implemented as a dictionary.

SortedList <TKey, TValue> SortedDictionary memory than using <TKey, TValue> less

SortedDictionary <TKey, TValue> element insertion and deletion operations faster.

When filled with the set data are sorted, if need to modify the capacity, SortedList <TKey, TValue> relatively quickly.

Collection

Comprising a set of elements is called Unique sets (set) .Net Framework comprises two sets (HashSet <T> and SortedSet <T>), they all implement ISet <T> interface.

HashSet <T> unordered list comprising a set of elements is not repeated, SortedSet <T> set comprising an ordered list will not be repeated

Guess you like

Origin www.cnblogs.com/SignX/p/11285931.html