Class XbimMultiValueDictionary<TKey, TValue>
A MultiValueDictionary can be viewed as a System.Collections.IDictionary that allows multiple values for any given unique key. While the MultiValueDictionary API is mostly the same as that of a regular System.Collections.IDictionary, there is a distinction in that getting the value for a key returns a System.Collections.Generic.ICollection<T> of values rather than a single value associated with that key. Additionally, there is functionality to allow adding or removing more than a single value at once.
The MultiValueDictionary can also be viewed as a IReadOnlyDictionary<TKey,ICollection<TValue>t> where the System.Collections.Generic.ICollection<T> is abstracted from the view of the programmer.
For a read-only MultiValueDictionary, see System.Linq.ILookup`2.
Inheritance
Implements
Inherited Members
Namespace: System.Collections.Generic
Assembly: Xbim.Common.dll
Syntax
public class XbimMultiValueDictionary<TKey, TValue> : IDictionary<TKey, ICollection<TValue>>, ICollection<KeyValuePair<TKey, ICollection<TValue>>>, IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>, IEnumerable
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the key. |
| TValue | The type of the value. |
Constructors
| Improve this Doc View SourceXbimMultiValueDictionary()
Initializes a new instance of the XbimMultiValueDictionary<TKey, TValue>
class that is empty, has the default initial capacity, and uses the default
System.Collections.Generic.IEqualityComparer<T> for TKey.
Declaration
public XbimMultiValueDictionary()
XbimMultiValueDictionary(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>)
Initializes a new instance of the XbimMultiValueDictionary<TKey, TValue> class that contains
elements copied from the specified IEnumerable<KeyValuePair<TKey, ICollection<TValue>>> and uses the
default System.Collections.Generic.IEqualityComparer<T> for the TKey type.
Declaration
public XbimMultiValueDictionary(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>> enumerable)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>>> | enumerable | IEnumerable to copy elements into this from |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | enumerable must be non-null |
XbimMultiValueDictionary(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>, IEqualityComparer<TKey>)
Initializes a new instance of the XbimMultiValueDictionary<TKey, TValue> class that contains elements copied from the specified IEnumerable<KeyValuePair<TKey, ICollection<TValue>>> and uses the specified System.Collections.Generic.IEqualityComparer<T>.
Declaration
public XbimMultiValueDictionary(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>> enumerable, IEqualityComparer<TKey> comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>>> | enumerable | IEnumerable to copy elements into this from |
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | Specified comparer to use for the |
Remarks
If comparer is set to null, then the default System.Collections.IEqualityComparer for TKey is used.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | enumerable must be non-null |
XbimMultiValueDictionary(IEqualityComparer<TKey>)
Initializes a new instance of the XbimMultiValueDictionary<TKey, TValue> class that is empty, has the default initial capacity, and uses the specified System.Collections.Generic.IEqualityComparer<T>.
Declaration
public XbimMultiValueDictionary(IEqualityComparer<TKey> comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | Specified comparer to use for the |
Remarks
If comparer is set to null, then the default System.Collections.IEqualityComparer for TKey is used.
XbimMultiValueDictionary(Int32)
Initializes a new instance of the XbimMultiValueDictionary<TKey, TValue> class that is
empty, has the specified initial capacity, and uses the default System.Collections.Generic.IEqualityComparer<T>
for TKey.
Declaration
public XbimMultiValueDictionary(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | capacity | Initial number of keys that the XbimMultiValueDictionary<TKey, TValue> will allocate space for |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | capacity must be >= 0 |
XbimMultiValueDictionary(Int32, IEqualityComparer<TKey>)
Initializes a new instance of the XbimMultiValueDictionary<TKey, TValue> class that is empty, has the specified initial capacity, and uses the specified System.Collections.Generic.IEqualityComparer<T>.
Declaration
public XbimMultiValueDictionary(int capacity, IEqualityComparer<TKey> comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | capacity | Initial number of keys that the XbimMultiValueDictionary<TKey, TValue> will allocate space for |
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | Specified comparer to use for the |
Remarks
If comparer is set to null, then the default System.Collections.IEqualityComparer for TKey is used.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Capacity must be >= 0 |
Properties
| Improve this Doc View SourceCount
Returns the number of TKeys with one or more associated TValue
in this XbimMultiValueDictionary<TKey, TValue>.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | The number of |
IsReadOnly
Declaration
public bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Item[TKey]
Get every TValue associated with the given TKey. If
key is not found in this XbimMultiValueDictionary<TKey, TValue>, will
throw a System.Collections.Generic.KeyNotFoundException.
Declaration
public ICollection<TValue> this[TKey key] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The |
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.ICollection<TValue> | An System.Collections.Generic.ICollection<T> containing every |
Remarks
Note that the System.Collections.Generic.ICollection<T> returned will change alongside any changes to the XbimMultiValueDictionary<TKey, TValue>
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
| System.Collections.Generic.KeyNotFoundException |
|
Keys
Gets each TKey in this XbimMultiValueDictionary<TKey, TValue> that
has one or more associated TValue.
Declaration
public IEnumerable<TKey> Keys { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<TKey> | An System.Collections.Generic.IEnumerable<T> containing each |
Values
Gets an enumerable of System.Collections.Generic.ICollection<T> from this XbimMultiValueDictionary<TKey, TValue>,
where each System.Collections.Generic.ICollection<T> is the collection of every TValue associated
with a TKey present in the XbimMultiValueDictionary<TKey, TValue>.
Declaration
public IEnumerable<ICollection<TValue>> Values { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<System.Collections.Generic.ICollection<TValue>> | An IEnumerable of each System.Collections.Generic.ICollection<T> in this XbimMultiValueDictionary<TKey, TValue> |
Methods
| Improve this Doc View SourceAdd(TKey, TValue)
Adds the specified TKey and TValue to the XbimMultiValueDictionary<TKey, TValue>.
Declaration
public void Add(TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The |
| TValue | value | The |
Remarks
Unlike the Add for System.Collections.IDictionary, the XbimMultiValueDictionary<TKey, TValue> Add will not
throw any exceptions. If the given TKey is already in the XbimMultiValueDictionary<TKey, TValue>,
then TValue will be added to System.Collections.Generic.ICollection<T> associated with key
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
Add(TKey, ICollection<TValue>)
Declaration
public void Add(TKey key, ICollection<TValue> value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | |
| System.Collections.Generic.ICollection<TValue> | value |
Add(KeyValuePair<TKey, ICollection<TValue>>)
Declaration
public void Add(KeyValuePair<TKey, ICollection<TValue>> item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>> | item |
AddRange(TKey, IEnumerable<TValue>)
Adds a number of key-value pairs to this XbimMultiValueDictionary<TKey, TValue>, where
the key for each value is key, and the value for a pair
is an element from values
Declaration
public void AddRange(TKey key, IEnumerable<TValue> values)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The |
| System.Collections.Generic.IEnumerable<TValue> | values | An System.Collections.Generic.IEnumerable<T> of values to add |
Remarks
A call to this AddRange method will always invalidate any currently running enumeration regardless of whether the AddRange method actually modified the XbimMultiValueDictionary<TKey, TValue>.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
Clear()
Removes every TKey and TValue from this
XbimMultiValueDictionary<TKey, TValue>.
Declaration
public void Clear()
Contains(TKey, TValue)
Determines if the given TKey-TValue
pair exists within this XbimMultiValueDictionary<TKey, TValue>.
Declaration
public bool Contains(TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The |
| TValue | value | The |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
Contains(KeyValuePair<TKey, ICollection<TValue>>)
Declaration
public bool Contains(KeyValuePair<TKey, ICollection<TValue>> item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>> | item |
Returns
| Type | Description |
|---|---|
| System.Boolean |
ContainsKey(TKey)
Determines if the given TKey exists within this XbimMultiValueDictionary<TKey, TValue> and has
at least one TValue associated with it.
Declaration
public bool ContainsKey(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ContainsValue(TValue)
Determines if the given TValue exists within this XbimMultiValueDictionary<TKey, TValue>.
Declaration
public bool ContainsValue(TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | A |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
CopyTo(KeyValuePair<TKey, ICollection<TValue>>[], Int32)
Declaration
public void CopyTo(KeyValuePair<TKey, ICollection<TValue>>[] array, int arrayIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>>[] | array | |
| System.Int32 | arrayIndex |
Create<TValueCollection>()
Creates a new new instance of the XbimMultiValueDictionary<TKey, TValue>
class that is empty, has the default initial capacity, and uses the default
System.Collections.Generic.IEqualityComparer<T> for TKey. The
internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>()
where TValueCollection : ICollection<TValue>, new()
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
Note that TValueCollection must implement System.Collections.Generic.ICollection<T>
in addition to being constructable through new(). The collection returned from the constructor
must also not have IsReadOnly set to True by default.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException |
|
Create<TValueCollection>(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>)
Initializes a new instance of the XbimMultiValueDictionary<TKey, TValue> class that contains
elements copied from the specified IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>
and uses the default System.Collections.Generic.IEqualityComparer<T> for the TKey type.
The internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>> enumerable)
where TValueCollection : ICollection<TValue>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>>> | enumerable | IEnumerable to copy elements into this from |
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
Note that TValueCollection must implement System.Collections.Generic.ICollection<T>
in addition to being constructable through new(). The collection returned from the constructor
must also not have IsReadOnly set to True by default.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException |
|
| System.ArgumentNullException | enumerable must be non-null |
Create<TValueCollection>(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>, IEqualityComparer<TKey>)
Initializes a new instance of the XbimMultiValueDictionary<TKey, TValue> class that contains
elements copied from the specified IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>
and uses the specified System.Collections.Generic.IEqualityComparer<T> for the TKey type.
The internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>> enumerable, IEqualityComparer<TKey> comparer)
where TValueCollection : ICollection<TValue>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>>> | enumerable | IEnumerable to copy elements into this from |
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | Specified comparer to use for the |
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
If comparer is set to null, then the default System.Collections.IEqualityComparer for TKey is used.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException |
|
| System.ArgumentNullException | enumerable must be non-null |
Create<TValueCollection>(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>, IEqualityComparer<TKey>, Func<TValueCollection>)
Initializes a new instance of the XbimMultiValueDictionary<TKey, TValue> class that contains
elements copied from the specified IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>
and uses the specified System.Collections.Generic.IEqualityComparer<T> for the TKey type.
The internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>> enumerable, IEqualityComparer<TKey> comparer, Func<TValueCollection> collectionFactory)
where TValueCollection : ICollection<TValue>
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>>> | enumerable | IEnumerable to copy elements into this from |
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | Specified comparer to use for the |
| System.Func<TValueCollection> | collectionFactory | A function to create a new System.Collections.Generic.ICollection<T> to use in the internal dictionary store of this XbimMultiValueDictionary<TKey, TValue>. |
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
If comparer is set to null, then the default System.Collections.IEqualityComparer for TKey is used.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException |
|
| System.ArgumentNullException | enumerable must be non-null |
Create<TValueCollection>(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>, Func<TValueCollection>)
Initializes a new instance of the XbimMultiValueDictionary<TKey, TValue> class that contains
elements copied from the specified IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>
and uses the default System.Collections.Generic.IEqualityComparer<T> for the TKey type.
The internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>(IEnumerable<KeyValuePair<TKey, ICollection<TValue>>> enumerable, Func<TValueCollection> collectionFactory)
where TValueCollection : ICollection<TValue>
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>>> | enumerable | IEnumerable to copy elements into this from |
| System.Func<TValueCollection> | collectionFactory | A function to create a new System.Collections.Generic.ICollection<T> to use in the internal dictionary store of this XbimMultiValueDictionary<TKey, TValue>. |
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
Note that TValueCollection must implement System.Collections.Generic.ICollection<T>
in addition to being constructable through new(). The collection returned from the constructor
must also not have IsReadOnly set to True by default.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException |
|
| System.ArgumentNullException | enumerable must be non-null |
Create<TValueCollection>(IEqualityComparer<TKey>)
Creates a new new instance of the XbimMultiValueDictionary<TKey, TValue>
class that is empty, has the default initial capacity, and uses the specified
System.Collections.Generic.IEqualityComparer<T> for TKey. The
internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>(IEqualityComparer<TKey> comparer)
where TValueCollection : ICollection<TValue>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | Specified comparer to use for the |
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
If comparer is set to null, then the default System.Collections.IEqualityComparer for TKey is used.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException |
|
Create<TValueCollection>(IEqualityComparer<TKey>, Func<TValueCollection>)
Creates a new new instance of the XbimMultiValueDictionary<TKey, TValue>
class that is empty, has the default initial capacity, and uses the specified
System.Collections.Generic.IEqualityComparer<T> for TKey. The
internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>(IEqualityComparer<TKey> comparer, Func<TValueCollection> collectionFactory)
where TValueCollection : ICollection<TValue>
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | Specified comparer to use for the |
| System.Func<TValueCollection> | collectionFactory | A function to create a new System.Collections.Generic.ICollection<T> to use in the internal dictionary store of this XbimMultiValueDictionary<TKey, TValue>. |
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
If comparer is set to null, then the default System.Collections.IEqualityComparer for TKey is used.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException |
|
Create<TValueCollection>(Func<TValueCollection>)
Creates a new new instance of the XbimMultiValueDictionary<TKey, TValue>
class that is empty, has the default initial capacity, and uses the default
System.Collections.Generic.IEqualityComparer<T> for TKey. The
internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>(Func<TValueCollection> collectionFactory)
where TValueCollection : ICollection<TValue>
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<TValueCollection> | collectionFactory | A function to create a new System.Collections.Generic.ICollection<T> to use in the internal dictionary store of this XbimMultiValueDictionary<TKey, TValue>. |
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
Note that TValueCollection must implement System.Collections.Generic.ICollection<T>
in addition to being constructable through new(). The collection returned from the constructor
must also not have IsReadOnly set to True by default.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException |
|
Create<TValueCollection>(Int32)
Creates a new new instance of the XbimMultiValueDictionary<TKey, TValue>
class that is empty, has the specified initial capacity, and uses the default
System.Collections.Generic.IEqualityComparer<T> for TKey. The
internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>(int capacity)
where TValueCollection : ICollection<TValue>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | capacity | Initial number of keys that the XbimMultiValueDictionary<TKey, TValue> will allocate space for |
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
Note that TValueCollection must implement System.Collections.Generic.ICollection<T>
in addition to being constructable through new(). The collection returned from the constructor
must also not have IsReadOnly set to True by default.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Capacity must be >= 0 |
| System.InvalidOperationException |
|
Create<TValueCollection>(Int32, IEqualityComparer<TKey>)
Creates a new new instance of the XbimMultiValueDictionary<TKey, TValue>
class that is empty, has the specified initial capacity, and uses the specified
System.Collections.Generic.IEqualityComparer<T> for TKey. The
internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>(int capacity, IEqualityComparer<TKey> comparer)
where TValueCollection : ICollection<TValue>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | capacity | Initial number of keys that the XbimMultiValueDictionary<TKey, TValue> will allocate space for |
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | Specified comparer to use for the |
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
If comparer is set to null, then the default System.Collections.IEqualityComparer for TKey is used.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException |
|
| System.ArgumentOutOfRangeException | Capacity must be >= 0 |
Create<TValueCollection>(Int32, IEqualityComparer<TKey>, Func<TValueCollection>)
Creates a new new instance of the XbimMultiValueDictionary<TKey, TValue>
class that is empty, has the specified initial capacity, and uses the specified
System.Collections.Generic.IEqualityComparer<T> for TKey. The
internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>(int capacity, IEqualityComparer<TKey> comparer, Func<TValueCollection> collectionFactory)
where TValueCollection : ICollection<TValue>
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | capacity | Initial number of keys that the XbimMultiValueDictionary<TKey, TValue> will allocate space for |
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | Specified comparer to use for the |
| System.Func<TValueCollection> | collectionFactory | A function to create a new System.Collections.Generic.ICollection<T> to use in the internal dictionary store of this XbimMultiValueDictionary<TKey, TValue>. |
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
If comparer is set to null, then the default System.Collections.IEqualityComparer for TKey is used.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException |
|
| System.ArgumentOutOfRangeException | Capacity must be >= 0 |
Create<TValueCollection>(Int32, Func<TValueCollection>)
Creates a new new instance of the XbimMultiValueDictionary<TKey, TValue>
class that is empty, has the specified initial capacity, and uses the default
System.Collections.Generic.IEqualityComparer<T> for TKey. The
internal dictionary will use instances of the TValueCollection
class as its collection type.
Declaration
public static XbimMultiValueDictionary<TKey, TValue> Create<TValueCollection>(int capacity, Func<TValueCollection> collectionFactory)
where TValueCollection : ICollection<TValue>
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | capacity | Initial number of keys that the XbimMultiValueDictionary<TKey, TValue> will allocate space for |
| System.Func<TValueCollection> | collectionFactory | A function to create a new System.Collections.Generic.ICollection<T> to use in the internal dictionary store of this XbimMultiValueDictionary<TKey, TValue>. |
Returns
| Type | Description |
|---|---|
| XbimMultiValueDictionary<TKey, TValue> | A new XbimMultiValueDictionary<TKey, TValue> with the specified parameters. |
Type Parameters
| Name | Description |
|---|---|
| TValueCollection | The collection type that this XbimMultiValueDictionary<TKey, TValue> will contain in its internal dictionary. |
Remarks
Note that TValueCollection must implement System.Collections.Generic.ICollection<T>
in addition to being constructable through new(). The collection returned from the constructor
must also not have IsReadOnly set to True by default.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Capacity must be >= 0 |
| System.InvalidOperationException |
|
GetEnumerator()
Get an Enumerator over the TKey-System.Collections.Generic.ICollection<T>
pairs in this XbimMultiValueDictionary<TKey, TValue>.
Declaration
public IEnumerator<KeyValuePair<TKey, ICollection<TValue>>> GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>>> | an Enumerator over the |
Remove(TKey)
Removes every TValue associated with the given TKey
from the XbimMultiValueDictionary<TKey, TValue>.
Declaration
public bool Remove(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
Remove(TKey, TValue)
Removes the first instance (if any) of the given TKey-TValue
pair from this XbimMultiValueDictionary<TKey, TValue>.
Declaration
public bool Remove(TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The |
| TValue | value | The |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Remarks
If the TValue being removed is the last one associated with its TKey, then that
TKey will be removed from the XbimMultiValueDictionary<TKey, TValue> and its
associated System.Collections.Generic.ICollection<T> will be freed as if a call to Remove(TKey)
had been made.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
Remove(KeyValuePair<TKey, ICollection<TValue>>)
Declaration
public bool Remove(KeyValuePair<TKey, ICollection<TValue>> item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>> | item |
Returns
| Type | Description |
|---|---|
| System.Boolean |
TryGetValue(TKey, out ICollection<TValue>)
Attempts to get the TValue associated with the given
TKey and place it into value.
Declaration
public bool TryGetValue(TKey key, out ICollection<TValue> value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The |
| System.Collections.Generic.ICollection<TValue> | value | When this method returns, contains the |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
Explicit Interface Implementations
| Improve this Doc View SourceIDictionary<TKey, ICollection<TValue>>.Item[TKey]
Declaration
ICollection<TValue> IDictionary<TKey, ICollection<TValue>>.this[TKey key] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.ICollection<TValue> |
IDictionary<TKey, ICollection<TValue>>.Keys
Declaration
ICollection<TKey> IDictionary<TKey, ICollection<TValue>>.Keys { get; }
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.ICollection<TKey> |
IDictionary<TKey, ICollection<TValue>>.Values
Declaration
ICollection<ICollection<TValue>> IDictionary<TKey, ICollection<TValue>>.Values { get; }
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.ICollection<System.Collections.Generic.ICollection<TValue>> |
IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>.GetEnumerator()
Declaration
IEnumerator<KeyValuePair<TKey, ICollection<TValue>>> IEnumerable<KeyValuePair<TKey, ICollection<TValue>>>.GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.ICollection<TValue>>> |
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.IEnumerator |