MultiDictionaryTKey, TValue Class |
The MultiDictionary class that associates values with a key. Unlike an Dictionary, each key can have multiple values associated with it. When indexing an MultiDictionary, instead of a single value associated with a key, you retrieve an enumeration of values.
When constructed, you can chose to allow the same value to be associated with a key multiple times, or only one time.
Namespace: X3Platform.Collections
[SerializableAttribute] public class MultiDictionary<TKey, TValue> : MultiDictionaryBase<TKey, TValue>, ICloneable
The MultiDictionaryTKey, TValue type exposes the following members.
Name | Description | |
---|---|---|
![]() | MultiDictionaryTKey, TValue(Boolean) |
Create a new MultiDictionary. The default ordering of keys and values are used. If duplicate values
are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo"
could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can
be associated with the same key, although different keys can have the same value. For example, the key "foo" could
have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it.
|
![]() | MultiDictionaryTKey, TValue(Boolean, IEqualityComparerTKey) |
Create a new MultiDictionary. If duplicate values
are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo"
could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can
be associated with the same key, although different keys can have the same value. For example, the key "foo" could
have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it.
|
![]() | MultiDictionaryTKey, TValue(Boolean, IEqualityComparerTKey, IEqualityComparerTValue) |
Create a new MultiDictionary. If duplicate values
are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo"
could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can
be associated with the same key, although different keys can have the same value. For example, the key "foo" could
have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it.
|
Name | Description | |
---|---|---|
![]() | Add(KeyValuePairTKey, ICollectionTValue) |
Adds a key-value pair to the collection. The value part of the pair must be a collection
of values to associate with the key. If values are already associated with the given
key, the new values are added to the ones associated with that key.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | Add(TKey, TValue) | Adds a new value to be associated with a key. If duplicate values are permitted, this method always adds a new key-value pair to the dictionary. If duplicate values are not permitted, and key already has a value equal to value associated with it, then that value is replaced with value, and the number of values associate with key is unchanged. |
![]() | AddMany | Adds new values to be associated with a key. If duplicate values are permitted, this method always adds new key-value pairs to the dictionary. If duplicate values are not permitted, and key already has a value equal to one of values associated with it, then that value is replaced, and the number of values associate with key is unchanged. |
![]() | AsReadOnly |
Provides a read-only view of this collection. The returned ICollection<T> provides
a view of the collection that prevents modifications to the collection. Use the method to provide
access to the collection without allowing changes. Since the returned object is just a view,
changes to the collection will be reflected in the view.
(Inherited from CollectionBaseT.) |
![]() | Clear |
Removes all keys and values from the dictionary.
(Overrides MultiDictionaryBaseTKey, TValueClear.) |
![]() | Clone |
Makes a shallow clone of this dictionary; i.e., if keys or values of the
dictionary are reference types, then they are not cloned. If TKey or TValue is a value type,
then each element is copied as if by simple assignment.
|
![]() | CloneContents |
Makes a deep clone of this dictionary. A new dictionary is created with a clone of
each entry of this dictionary, by calling ICloneable.Clone on each element. If TKey or TValue is
a value type, then each element is copied as if by simple assignment.
|
![]() | Contains(KeyValuePairTKey, ICollectionTValue) |
Determines if this dictionary contains the given key and all of the values associated with that key..
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | Contains(TKey, TValue) |
Checks to see if value is associated with key
in the dictionary.
(Overrides MultiDictionaryBaseTKey, TValueContains(TKey, TValue).) |
![]() | ContainsKey |
Checks to see if the key is present in the dictionary and has
at least one value associated with it.
(Overrides MultiDictionaryBaseTKey, TValueContainsKey(TKey).) |
![]() | ConvertAllTOutput |
Convert this collection of items by applying a delegate to each item in the collection. The resulting enumeration
contains the result of applying converter to each item in this collection, in
order.
(Inherited from CollectionBaseT.) |
![]() | CopyTo |
Copies all the items in the collection into an array. Implemented by
using the enumerator returned from GetEnumerator to get all the items
and copy them to the provided array.
(Inherited from CollectionBaseT.) |
![]() | CountAllValues |
Gets a total count of values in the collection. This default implementation
is slow; it enumerates all of the keys in the dictionary and calls CountValues on each.
A derived class may be able to supply a more efficient implementation.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | CountValues |
Gets the number of values associated with a given key.
(Overrides MultiDictionaryBaseTKey, TValueCountValues(TKey).) |
![]() | CountWhere |
Counts the number of items in the collection that satisfy the condition
defined by predicate.
(Inherited from CollectionBaseT.) |
![]() | EnumerateKeys |
Enumerate all the keys in the dictionary.
(Overrides MultiDictionaryBaseTKey, TValueEnumerateKeys.) |
![]() | Equals | (Inherited from Object.) |
![]() | EqualValues |
Determine if two values are equal.
(Overrides MultiDictionaryBaseTKey, TValueEqualValues(TValue, TValue).) |
![]() | Exists |
Determines if the collection contains any item that satisfies the condition
defined by predicate.
(Inherited from CollectionBaseT.) |
![]() | Finalize | (Inherited from Object.) |
![]() | FindAll |
Enumerates the items in the collection that satisfy the condition defined
by predicate.
(Inherited from CollectionBaseT.) |
![]() | ForEach |
Performs the specified action on each item in this collection.
(Inherited from CollectionBaseT.) |
![]() | GetEnumerator |
Enumerate all the keys in the dictionary, and for each key, the collection of values for that key.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() | MemberwiseClone | (Inherited from Object.) |
![]() | Remove(TKey) |
Removes a key and all associated values from the dictionary. If the
key is not present in the dictionary, it is unchanged and false is returned.
(Overrides MultiDictionaryBaseTKey, TValueRemove(TKey).) |
![]() | Remove(KeyValuePairTKey, ICollectionTValue) |
Removes a set of values from a given key. If all values associated with a key are
removed, then the key is removed also.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | Remove(TKey, TValue) |
Removes a given value from the values associated with a key. If the
last value is removed from a key, the key is removed also.
(Overrides MultiDictionaryBaseTKey, TValueRemove(TKey, TValue).) |
![]() | RemoveAll |
Removes all the items in the collection that satisfy the condition
defined by predicate.
(Inherited from CollectionBaseT.) |
![]() | RemoveMany(IEnumerableTKey) |
Remove all of the keys (and any associated values) in a collection
of keys. If a key is not present in the dictionary, nothing happens.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | RemoveMany(TKey, IEnumerableTValue) |
Removes a collection of values from the values associated with a key. If the
last value is removed from a key, the key is removed also.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | Replace |
Replaces all values associated with key with the single value value.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | ReplaceMany |
Replaces all values associated with key with a new collection
of values. If the collection does not permit duplicate values, and values has duplicate
items, then only the last of duplicates is added.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | ToArray |
Creates an array of the correct size, and copies all the items in the
collection into the array, by calling CopyTo.
(Inherited from CollectionBaseT.) |
![]() | ToString |
Shows the string representation of the dictionary. The string representation contains
a list of the mappings in the dictionary.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | TrueForAll |
Determines if all of the items in the collection satisfy the condition
defined by predicate.
(Inherited from CollectionBaseT.) |
![]() | TryEnumerateValuesForKey |
Determines if this dictionary contains a key equal to key. If so, all the values
associated with that key are returned through the values parameter.
(Overrides MultiDictionaryBaseTKey, TValueTryEnumerateValuesForKey(TKey, IEnumeratorTValue).) |
Name | Description | |
---|---|---|
![]() | Count |
Gets the number of key-value pairs in the dictionary. Each value associated
with a given key is counted. If duplicate values are permitted, each duplicate
value is included in the count.
(Overrides MultiDictionaryBaseTKey, TValueCount.) |
![]() | Item |
Returns a collection of all of the values in the dictionary associated with key,
or changes the set of values associated with key.
If the key is not present in the dictionary, an ICollection enumerating no
values is returned. The returned collection of values is read-write, and can be used to
modify the collection of values associated with the key.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | KeyComparer |
Returns the IEqualityComparer<T> used to compare keys in this dictionary.
|
![]() | Keys |
Gets a read-only collection all the keys in this dictionary.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | KeyValuePairs |
Gets a read-only collection of all key-value pairs in the dictionary. If a key has multiple
values associated with it, then a key-value pair is present for each value associated
with the key.
(Inherited from MultiDictionaryBaseTKey, TValue.) |
![]() | ValueComparer |
Returns the IEqualityComparer<T> used to compare values in this dictionary.
|
![]() | Values |
Gets a read-only collection of all the values in the dictionary.
(Inherited from MultiDictionaryBaseTKey, TValue.) |