Class D<T, U>
- Namespace
- SunamoCollectionsGeneric.Collections
- Assembly
- SunamoCollectionsGeneric.dll
Dictionary implementation with debugging capabilities and enumerable support Must be IEnumerable, not IList.
public class D<T, U> : IDictionary<T, U>, ICollection<KeyValuePair<T, U>>, IEnumerable<KeyValuePair<T, U>>, IEnumerable where T : notnull
Type Parameters
TThe type of keys in the dictionary.
UThe type of values in the dictionary.
- Inheritance
-
D<T, U>
- Implements
-
IDictionary<T, U>ICollection<KeyValuePair<T, U>>IEnumerable<KeyValuePair<T, U>>
- Inherited Members
- Extension Methods
Properties
CallWhenIsZeroElements
Gets or sets an action to call when attempting to access an empty dictionary
public Action? CallWhenIsZeroElements { get; set; }
Property Value
Count
Gets the number of key/value pairs contained in the dictionary
public int Count { get; }
Property Value
IsReadOnly
Gets a value indicating whether the dictionary is read-only
public bool IsReadOnly { get; }
Property Value
this[T]
Gets or sets the value associated with the specified key
public U this[T key] { get; set; }
Parameters
keyTThe key of the value to get or set
Property Value
- U
The value associated with the specified key
Keys
Gets a collection containing the keys in the dictionary
public ICollection<T> Keys { get; }
Property Value
- ICollection<T>
Values
Gets a collection containing the values in the dictionary
public ICollection<U> Values { get; }
Property Value
- ICollection<U>
Methods
Add(KeyValuePair<T, U>)
Adds the specified key/value pair to the dictionary
public void Add(KeyValuePair<T, U> pair)
Parameters
pairKeyValuePair<T, U>The key/value pair to add
Add(T, U)
Adds the specified key and value to the dictionary
public void Add(T key, U value)
Parameters
keyTThe key to add
valueUThe value to add
Clear()
Removes all keys and values from the dictionary
public void Clear()
Contains(KeyValuePair<T, U>)
Determines whether the dictionary contains the specified key/value pair
public bool Contains(KeyValuePair<T, U> pair)
Parameters
pairKeyValuePair<T, U>The key/value pair to locate
Returns
- bool
True if the pair is found; otherwise, false
ContainsKey(T)
Determines whether the dictionary contains the specified key
public bool ContainsKey(T key)
Parameters
keyTThe key to locate
Returns
- bool
True if the dictionary contains an element with the specified key; otherwise, false
CopyTo(KeyValuePair<T, U>[], int)
Copies the elements of the dictionary to an array, starting at the specified array index
public void CopyTo(KeyValuePair<T, U>[] array, int arrayIndex)
Parameters
arrayKeyValuePair<T, U>[]The destination array
arrayIndexintThe zero-based index in array at which copying begins
GetEnumerator()
Returns an enumerator that iterates through the dictionary
public IEnumerator<KeyValuePair<T, U>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<T, U>>
An enumerator for the dictionary
Remove(KeyValuePair<T, U>)
Removes the specified key/value pair from the dictionary
public bool Remove(KeyValuePair<T, U> pair)
Parameters
pairKeyValuePair<T, U>The key/value pair to remove
Returns
- bool
True if the pair is successfully found and removed; otherwise, false
Remove(T)
Removes the value with the specified key from the dictionary
public bool Remove(T key)
Parameters
keyTThe key of the element to remove
Returns
- bool
True if the element is successfully found and removed; otherwise, false
TryGetValue(T, out U)
Gets the value associated with the specified key
public bool TryGetValue(T key, out U value)
Parameters
keyTThe key of the value to get
valueUWhen this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value
Returns
- bool
True if the dictionary contains an element with the specified key; otherwise, false