mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-12 03:05:06 +00:00
fix: Better set key/value behaviour for BiDictionary
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user