mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-13 20:47:24 +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)
|
if (value == null)
|
||||||
throw new ArgumentNullException("value");
|
throw new ArgumentNullException("value");
|
||||||
|
|
||||||
// Prevent building a 2-to-1 mapping
|
RemoveKey(key);
|
||||||
if (ContainsKey(key) ^ ContainsValue(value))
|
RemoveValue(value);
|
||||||
throw new InvalidOperationException(
|
|
||||||
"Can not set key and value when either key or value are already present in the collection");
|
|
||||||
|
|
||||||
m_KeyToValue[key] = value;
|
Add(key, value);
|
||||||
m_ValueToKey[value] = key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TKey GetKey(TValue value)
|
public TKey GetKey(TValue value)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue