mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
fix: Better set key/value behaviour for BiDictionary
This commit is contained in:
parent
8d683f875b
commit
2fab5d6fd4
1 changed files with 3 additions and 6 deletions
|
|
@ -83,13 +83,10 @@ namespace ICD.Common.Utils.Collections
|
|||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
|
||||
// Prevent building a 2-to-1 mapping
|
||||
if (ContainsKey(key) ^ ContainsValue(value))
|
||||
throw new InvalidOperationException(
|
||||
"Can not set key and value when either key or value are already present in the collection");
|
||||
RemoveKey(key);
|
||||
RemoveValue(value);
|
||||
|
||||
m_KeyToValue[key] = value;
|
||||
m_ValueToKey[value] = key;
|
||||
Add(key, value);
|
||||
}
|
||||
|
||||
public TKey GetKey(TValue value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue