Enhanced C#
Language of your choice: library documentation
|
Common base class that contains code shared between Map{K,V} and MMap{K,V}. More...
Common base class that contains code shared between Map{K,V} and MMap{K,V}.
You might notice that although Map{K,V} and MMap{K,V} have a common base class, Set{T} and MSet{T} do not, and this is a mere implementation detail. Since Set{T} is immutable, and small, and its fields can safely be initialized to 0 or null, its default value is a valid set and it makes sense to implement is as a struct. The same observation would apply to Map{K,V} except for one problem: the comparer. The user can supply a comparer of type IEqualityComparer<K>
, but but Map{K,V} contains a set of type InternalSet<KeyValuePair<K,V>>
, which requires a comparer of type IEqualityComparer<KeyValuePair<K,V>>
. In general, a wrapper object is necessary to provide this comparer, and I decided to use the set itself as the wrapper object. Therefore, Map{K,V} implements this interface, and it must be a class so that it is not boxed every time it is converted to this interface.
Finally, since Map{K,V} and MMap{K,V} are both classes and share some of the same code, I decided to factor out the common code into this base class. The end.
Properties | |
bool | IsEmpty [get] |
IEqualityComparer< K > | KeyComparer [get] |
InternalSet< KeyValuePair< K, V > > | FrozenInternalSet [get] |
V | this[K key] [get] |
V | this[K key, V defaultValue] [get] |
Retrieves the value associated with the specified key, or returns defaultValue if the key is not found. More... | |
int | Count [get] |
IEnumerable< K > | Keys [get] |
IEnumerable< V > | Values [get] |
Public Member Functions | |
bool | ContainsKey (K key) |
bool | TryGetValue (K key, out V value) |
bool | Contains (KeyValuePair< K, V > item) |
void | CopyTo (KeyValuePair< K, V >[] array, int arrayIndex) |
InternalSet< KeyValuePair< K, V > >.Enumerator | GetEnumerator () |
V | TryGetValue (K key, V defaultValue) |
Synonym for this[key, defaultValue]. More... | |
virtual long | CountMemory (int sizeOfPair) |
Measures the total size of all objects allocated to this collection, in bytes, including the size of this object itself; see InternalSet{T}.CountMemory. More... | |
Protected static fields | |
static readonly EqualityComparer< V > | DefaultValueComparer = EqualityComparer<V>.Default |
|
inlinevirtual |
Measures the total size of all objects allocated to this collection, in bytes, including the size of this object itself; see InternalSet{T}.CountMemory.
|
inline |
Synonym for this[key, defaultValue].
|
get |
Retrieves the value associated with the specified key, or returns defaultValue
if the key is not found.