SortedDictionary<TKey,TValue>.KeyCollection Class
Definition
Represents the collection of keys in a SortedDictionary<TKey,TValue>. This class cannot be inherited.
public: ref class SortedDictionary<TKey, TValue>::KeyCollection sealed : System::Collections::Generic::ICollection<TKey>, System::Collections::Generic::IEnumerable<TKey>, System::Collections::Generic::IReadOnlyCollection<TKey>, System::Collections::ICollection
[System.Serializable]
public sealed class SortedDictionary<TKey,TValue>.KeyCollection : System.Collections.Generic.ICollection<TKey>, System.Collections.Generic.IEnumerable<TKey>, System.Collections.Generic.IReadOnlyCollection<TKey>, System.Collections.ICollection
type SortedDictionary<'Key, 'Value>.KeyCollection = class
interface ICollection<'Key>
interface ICollection
interface IReadOnlyCollection<'Key>
interface seq<'Key>
interface IEnumerable
Public NotInheritable Class SortedDictionary(Of TKey, TValue).KeyCollection
Implements ICollection, ICollection(Of TKey), IEnumerable(Of TKey), IReadOnlyCollection(Of TKey)
Type Parameters
- TKey
- TValue
- Inheritance
-
SortedDictionary<TKey,TValue>.KeyCollection
- Attributes
- Implements
-
ICollection<TKey> IEnumerable<T> IEnumerable<TKey> IReadOnlyCollection<TKey> ICollection IEnumerable
Remarks
The SortedDictionary<TKey,TValue>.Keys property returns an instance of this type, containing all the keys in that SortedDictionary<TKey,TValue>. The order of the keys in the SortedDictionary<TKey,TValue>.KeyCollection is the same as the order of elements in the SortedDictionary<TKey,TValue>, the same as the order of the associated values in the SortedDictionary<TKey,TValue>.ValueCollection returned by the SortedDictionary<TKey,TValue>.Values property.
The SortedDictionary<TKey,TValue>.KeyCollection is not a static copy; instead, the SortedDictionary<TKey,TValue>.KeyCollection refers back to the keys in the original SortedDictionary<TKey,TValue>. Therefore, changes to the SortedDictionary<TKey,TValue> continue to be reflected in the SortedDictionary<TKey,TValue>.KeyCollection.
Constructors
SortedDictionary<TKey,TValue>.KeyCollection(SortedDictionary<TKey,TValue>) |
Initializes a new instance of the SortedDictionary<TKey,TValue>.KeyCollection class that reflects the keys in the specified SortedDictionary<TKey,TValue>. |
Properties
Count |
Gets the number of elements contained in the SortedDictionary<TKey,TValue>.KeyCollection. |
Methods
CopyTo(TKey[], Int32) |
Copies the SortedDictionary<TKey,TValue>.KeyCollection elements to an existing one-dimensional array, starting at the specified array index. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetEnumerator() |
Returns an enumerator that iterates through the SortedDictionary<TKey,TValue>.KeyCollection. |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
Explicit Interface Implementations
ICollection.CopyTo(Array, Int32) |
Copies the elements of the ICollection to an array, starting at a particular array index. |
ICollection.IsSynchronized |
Gets a value indicating whether access to the ICollection is synchronized (thread safe). |
ICollection.SyncRoot |
Gets an object that can be used to synchronize access to the ICollection. |
ICollection<TKey>.Add(TKey) |
Adds an item to the ICollection<T>. This implementation always throws a NotSupportedException. |
ICollection<TKey>.Clear() |
Removes all items from the ICollection<T>. This implementation always throws a NotSupportedException. |
ICollection<TKey>.Contains(TKey) |
Determines whether the ICollection<T> contains the specified value. |
ICollection<TKey>.IsReadOnly |
Gets a value indicating whether the ICollection<T> is read-only. |
ICollection<TKey>.Remove(TKey) |
Removes the first occurrence of a specific object from the ICollection<T>. This implementation always throws a NotSupportedException. |
IEnumerable.GetEnumerator() |
Returns an enumerator that iterates through the collection. |
IEnumerable<TKey>.GetEnumerator() |
Returns an enumerator that iterates through the collection. |
Extension Methods
CopyToDataTable<T>(IEnumerable<T>) |
Returns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter |
CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) |
Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter |
CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) |
Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter |
Cast<TResult>(IEnumerable) |
Casts the elements of an IEnumerable to the specified type. |
OfType<TResult>(IEnumerable) |
Filters the elements of an IEnumerable based on a specified type. |
AsParallel(IEnumerable) |
Enables parallelization of a query. |
AsQueryable(IEnumerable) |
Converts an IEnumerable to an IQueryable. |
Ancestors<T>(IEnumerable<T>) |
Returns a collection of elements that contains the ancestors of every node in the source collection. |
Ancestors<T>(IEnumerable<T>, XName) |
Returns a filtered collection of elements that contains the ancestors of every node in the source collection. Only elements that have a matching XName are included in the collection. |
DescendantNodes<T>(IEnumerable<T>) |
Returns a collection of the descendant nodes of every document and element in the source collection. |
Descendants<T>(IEnumerable<T>) |
Returns a collection of elements that contains the descendant elements of every element and document in the source collection. |
Descendants<T>(IEnumerable<T>, XName) |
Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection. |
Elements<T>(IEnumerable<T>) |
Returns a collection of the child elements of every element and document in the source collection. |
Elements<T>(IEnumerable<T>, XName) |
Returns a filtered collection of the child elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection. |
InDocumentOrder<T>(IEnumerable<T>) |
Returns a collection of nodes that contains all nodes in the source collection, sorted in document order. |
Nodes<T>(IEnumerable<T>) |
Returns a collection of the child nodes of every document and element in the source collection. |
Remove<T>(IEnumerable<T>) |
Removes every node in the source collection from its parent node. |
Applies to
Thread Safety
Public static (Shared
in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
A SortedDictionary<TKey,TValue>.KeyCollection can support multiple readers concurrently, as long as the collection is not modified. Even so, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.