[SerializableAttribute]
public class CircularSortedList<TKey, TValue> : IDictionary<TKey, TValue>,
ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>,
IEnumerable, IList<KeyValuePair<TKey, TValue>>, IDictionary,
ICollection, IList, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>,
IReadOnlyList<KeyValuePair<TKey, TValue>>
<SerializableAttribute>
Public Class CircularSortedList(Of TKey, TValue)
Implements IDictionary(Of TKey, TValue), ICollection(Of KeyValuePair(Of TKey, TValue)),
IEnumerable(Of KeyValuePair(Of TKey, TValue)), IEnumerable,
IList(Of KeyValuePair(Of TKey, TValue)), IDictionary,
ICollection, IList, IReadOnlyDictionary(Of TKey, TValue), IReadOnlyCollection(Of KeyValuePair(Of TKey, TValue)),
IReadOnlyList(Of KeyValuePair(Of TKey, TValue))
[SerializableAttribute]
generic<typename TKey, typename TValue>
public ref class CircularSortedList : IDictionary<TKey, TValue>,
ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>,
IEnumerable, IList<KeyValuePair<TKey, TValue>>, IDictionary,
ICollection, IList, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>,
IReadOnlyList<KeyValuePair<TKey, TValue>>
[<SerializableAttribute>]
type CircularSortedList<'TKey, 'TValue> =
class
interface IDictionary<'TKey, 'TValue>
interface ICollection<KeyValuePair<'TKey, 'TValue>>
interface IEnumerable<KeyValuePair<'TKey, 'TValue>>
interface IEnumerable
interface IList<KeyValuePair<'TKey, 'TValue>>
interface IDictionary
interface ICollection
interface IList
interface IReadOnlyDictionary<'TKey, 'TValue>
interface IReadOnlyCollection<KeyValuePair<'TKey, 'TValue>>
interface IReadOnlyList<KeyValuePair<'TKey, 'TValue>>
end
The CircularSortedListTKey, TValue generic class is an array of key/value pairs with O(log n) retrieval, where n is the number of elements in the dictionary.
Similarly to SortedListTKey, TValue, CircularSortedListTKey, TValue supports efficient indexed retrieval of keys and values through the collections returned by the Keys and Values properties. It is not necessary to regenerate the lists when the properties are accessed, because the lists are just wrappers for the internal arrays of keys and values.
CircularSortedListTKey, TValue is implemented as a pair of CircularListT of key/value pairs, sorted by the key. Each element can be retrieved as a KeyValuePairTKey, TValue object.
Key objects must be immutable as long as they are used as keys in the CircularSortedListTKey, TValue. Every key in a CircularSortedListTKey, TValue must be unique. A key cannot be , but a value can be, if the type of values in the list, TValue, is a reference type, or is a NullableT type.
CircularSortedListTKey, TValue requires a comparer implementation to sort and to perform comparisons. If comparer is not defined when CircularSortedListTKey, TValue is instantiated by one of the constructors, the comparer will be chosen automatically. Only when targeting the .NET Framework, if TKey is an enum type, then the comparer will be the EnumComparer<TEnum>.Comparer. Otherwise, the default comparer Comparer<T>.Default will be chosen. The default comparer checks whether the key type TKey implements IComparableT and uses that implementation, if available. If not, Comparer<T>.Default checks whether the key type TKey implements IComparable. If the key type TKey does not implement either interface, you can specify an IComparableT implementation in a constructor overload that accepts a comparer parameter.
The capacity of a CircularSortedListTKey, TValue is the number of elements the CircularSortedListTKey, TValue can hold. As elements are added to a CircularSortedListTKey, TValue, the capacity is automatically increased as required by reallocating the internal array. The capacity can be decreased by calling TrimExcess or by setting the Capacity property explicitly. Decreasing the capacity reallocates memory and copies all the elements in the CircularSortedListTKey, TValue.
CircularSortedListTKey, TValue implements IListT as well, so it can be indexed directly when cast to IListT or though the AsList property:
KeyValuePair<int, string> firstItem = myCircularSortedList.AsList[0];
Collection type | Behavior |
---|---|
SortedDictionaryTKey, TValue |
|
SortedListTKey, TValue |
|
CircularSortedListTKey, TValue |
|
CircularSortedListTKey, TValue | Creates a new instance of CircularSortedListTKey, TValue with empty capacity and a default comparer. |
CircularSortedListTKey, TValue(IComparerTKey) | Creates a new instance of CircularSortedListTKey, TValue with empty capacity, that uses the specified comparer. |
CircularSortedListTKey, TValue(IDictionaryTKey, TValue, IComparerTKey) | Creates a new instance of CircularSortedListTKey, TValue, that initializes its elements from the provided dictionary, and uses the specified comparer. |
CircularSortedListTKey, TValue(Int32, IComparerTKey) | Creates a new instance of CircularSortedListTKey, TValue, that is empty, and has the specified initial capacity, and uses the specified comparer. |
AsList | Gets the CircularSortedListTKey, TValue cast to an IListT. |
Capacity | Gets or sets the actual size of the internal storage of held elements. |
Comparer | Gets the IComparerT that is used in the CircularSortedListTKey, TValue. |
Count | Gets the number of key/value pairs contained in the CircularSortedListTKey, TValue. |
Item | Gets or sets the value associated with the specified key. |
Keys | Gets an indexable list containing the keys in the CircularSortedListTKey, TValue, in sorted order. |
Values | Gets an indexable list containing the values in the CircularSortedListTKey, TValue, in the order of the sorted keys. |
Add | Adds an element with the provided key and value to the CircularSortedListTKey, TValue. |
Clear | Removes all items from the CircularSortedListTKey, TValue. |
ContainsKey | Determines whether the CircularSortedListTKey, TValue contains an element with the specified key. |
ContainsValue | Determines whether the CircularSortedListTKey, TValue contains a specific value. |
ElementAt | Gets a KeyValuePairTKey, TValue of the TKey and TValue elements at the specified index. |
EnsureCapacity | Ensures that the Capacity of the CircularSortedListTKey, TValue is at least the specified capacity. |
GetEnumerator | Returns an enumerator that iterates through the collection in the order of the sorted keys. |
GetKeyAtIndex | Gets the key of an element at the specified index. |
GetValueAtIndex | Gets the value of an element at the specified index. |
IndexOfKey | Searches for the specified key and returns the zero-based index within the entire CircularSortedListTKey, TValue. |
IndexOfValue | Searches for the specified value and returns the zero-based index of the first occurrence within the entire CircularSortedListTKey, TValue. |
Remove | Removes the element with the specified key from the CircularSortedListTKey, TValue. |
RemoveAt | Removes the element at the specified index of the CircularSortedListTKey, TValue. |
Reset | Removes all items from the CircularSortedListTKey, TValue and resets the Capacity to 0. |
SetValueAtIndex | Sets the value of an element at the specified index. |
TrimExcess | Sets the capacity to the actual number of elements in the CircularSortedListTKey, TValue, if that number is less than 90 percent of current capacity. |
TryGetValue | Gets the value associated with the specified key. |
AddRangeKeyValuePairTKey, TValue |
Adds a collection to the target ICollectionT.
(Defined by CollectionExtensions) |
AsThreadSafeKeyValuePairTKey, TValue |
Returns a LockingCollectionT, which provides a thread-safe wrapper for the specified collection.
This only means that if the members are accessed through the returned LockingCollectionT, then the inner state of the wrapped collection remains always consistent and not that all the multi-threading concerns can be ignored.
See the Remarks section of the LockingCollectionT class for details and some examples. (Defined by CollectionExtensions) |
AsThreadSafeKeyValuePairTKey, TValue |
Returns a LockingListT, which provides a thread-safe wrapper for the specified list.
This only means that if the members are accessed through the returned LockingListT, then the inner state of the wrapped list remains always consistent and not that all the multi-threading concerns can be ignored.
See the Remarks section of the LockingListT class for details and some examples. (Defined by ListExtensions) |
Convert |
Converts an Object specified in the obj parameter to the desired targetType.
See the Examples section of the generic ConvertTTarget(Object, CultureInfo) overload for an example. (Defined by ObjectExtensions) |
ConvertTTarget |
Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions) |
ForEachKeyValuePairTKey, TValue |
Similarly to the List<T>.ForEach method, processes an action on each element of an enumerable collection.
(Defined by EnumerableExtensions) |
GetRandomElementKeyValuePairTKey, TValue |
Gets a random element from the enumerable source using a new FastRandom instance.
(Defined by EnumerableExtensions) |
GetRandomElementKeyValuePairTKey, TValue |
Gets a random element from the enumerable source using a specified Random instance.
(Defined by EnumerableExtensions) |
In |
Gets whether item is among the elements of set.
See the Examples section of the generic InT(T, T) overload for an example. (Defined by ObjectExtensions) |
IndexOf |
Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions) |
IndexOf |
Searches for an element in the source enumeration.
(Defined by EnumerableExtensions) |
IndexOfKeyValuePairTKey, TValue |
Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions) |
IndexOfKeyValuePairTKey, TValue |
Searches for an element in the source enumeration.
(Defined by EnumerableExtensions) |
InsertRangeKeyValuePairTKey, TValue |
Inserts a collection into the target IListT.
(Defined by ListExtensions) |
IsNullOrEmpty |
Determines whether the specified source is or empty (has no elements).
(Defined by EnumerableExtensions) |
IsNullOrEmptyKeyValuePairTKey, TValue |
Determines whether the specified source is or empty (has no elements).
(Defined by EnumerableExtensions) |
JoinKeyValuePairTKey, TValue |
Concatenates the items of the source collection into a new string instance
using the specified separator between the items.
(Defined by EnumerableExtensions) |
JoinKeyValuePairTKey, TValue |
Concatenates the items of the source collection into a new string instance
using the specified separator between the items.
(Defined by EnumerableExtensions) |
RemoveRangeKeyValuePairTKey, TValue |
Removes count amount of items from the specified collection at the specified index.
(Defined by ListExtensions) |
ReplaceRangeKeyValuePairTKey, TValue |
Removes count amount of items from the target IListT at the specified index, and
inserts the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by ListExtensions) |
ShuffleKeyValuePairTKey, TValue |
Shuffles an enumerable source (randomizes its elements) using a new FastRandom instance.
(Defined by EnumerableExtensions) |
ShuffleKeyValuePairTKey, TValue |
Shuffles an enumerable source (randomizes its elements) using the provided seed with a new FastRandom instance.
(Defined by EnumerableExtensions) |
ShuffleKeyValuePairTKey, TValue |
Shuffles an enumerable source (randomizes its elements) using the provided seed with a new FastRandom instance.
(Defined by EnumerableExtensions) |
ShuffleKeyValuePairTKey, TValue |
Shuffles an enumerable source (randomizes its elements) using a specified Random instance.
(Defined by EnumerableExtensions) |
ToCircularListKeyValuePairTKey, TValue |
Creates a CircularListT from an IEnumerableT.
(Defined by EnumerableExtensions) |
ToStringKeyedDictionaryKeyValuePairTKey, TValue |
Creates a StringKeyedDictionaryTValue from an IEnumerableT instance using the specified keySelector delegate and a comparer.
(Defined by EnumerableExtensions) |
ToStringKeyedDictionaryKeyValuePairTKey, TValue, TValue |
Creates a StringKeyedDictionaryTValue from an IEnumerableT instance using the specified key and value selector delegates and a comparer.
(Defined by EnumerableExtensions) |
TryAdd |
Tries to add the specified item to the collection.
(Defined by EnumerableExtensions) |
TryAddKeyValuePairTKey, TValue |
Tries to add the specified item to the collection.
(Defined by EnumerableExtensions) |
TryAddRange |
Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions) |
TryAddRangeKeyValuePairTKey, TValue |
Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions) |
TryClear |
Tries to remove all elements from the collection.
(Defined by EnumerableExtensions) |
TryClearKeyValuePairTKey, TValue |
Tries to remove all elements from the collection.
(Defined by EnumerableExtensions) |
TryConvert |
Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example. (Defined by ObjectExtensions) |
TryConvert |
Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example. (Defined by ObjectExtensions) |
TryConvertTTarget |
Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example. (Defined by ObjectExtensions) |
TryConvertTTarget |
Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example. (Defined by ObjectExtensions) |
TryGetCount |
Tries to get the number of elements in the source enumeration without enumerating it.
(Defined by EnumerableExtensions) |
TryGetCountKeyValuePairTKey, TValue |
Tries to get the number of elements in the source enumeration without enumerating it.
(Defined by EnumerableExtensions) |
TryGetElementAt |
Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions) |
TryGetElementAtKeyValuePairTKey, TValue |
Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions) |
TryInsert |
Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions) |
TryInsertKeyValuePairTKey, TValue |
Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions) |
TryInsertRange |
Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions) |
TryInsertRangeKeyValuePairTKey, TValue |
Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions) |
TryRemove |
Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions) |
TryRemoveKeyValuePairTKey, TValue |
Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions) |
TryRemoveAt |
Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions) |
TryRemoveAtKeyValuePairTKey, TValue |
Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions) |
TryRemoveRange |
Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions) |
TryRemoveRangeKeyValuePairTKey, TValue |
Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions) |
TryReplaceRange |
Tries to remove count amount of items from the target at the specified index, and
to insert the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by EnumerableExtensions) |
TryReplaceRangeKeyValuePairTKey, TValue |
Tries to remove count amount of items from the target at the specified index, and
to insert the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by EnumerableExtensions) |
TrySetElementAt |
Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions) |
TrySetElementAtKeyValuePairTKey, TValue |
Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions) |