CircularSortedListTKey, TValueKeys Property

KGy SOFT Core Libraries Help

Namespace:  KGySoft.Collections
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.0.0-preview.3

public IList<TKey> Keys { get; }

Property Value

Type: IListTKey

The order of the keys in the IListT is the same as the order in the CircularSortedListTKey, TValue.

The returned IListT is not a static copy; instead, the IListT refers back to the keys in the original CircularSortedListTKey, TValue. Therefore, changes to the CircularSortedListTKey, TValue continue to be reflected in the returned IListT.

The collection returned by the Keys property provides an efficient way to retrieve keys by index. It is not necessary to regenerate the list when the property is accessed, because the list is just a wrapper for the internal CircularListT of keys. The following code shows the use of the Keys property for indexed retrieval of keys from a sorted list of elements with string keys:

string v = mySortedList.Keys[3];

Retrieving the value of this property is an O(1) operation.

Note Note
The enumerator of the returned collection supports the IEnumerator.Reset method.
See Also