mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-01-11 19:44:55 +00:00
feat: Adding Equality Comparers to BiDictionary constructor
This commit is contained in:
committed by
Chris Cameron
parent
f601f9cda7
commit
531e9dfcf8
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- Enum Extension "SetFlags", takes a bool to set or unset the given flags
|
||||
- BiDictionay - Added constructors with TKey and TValue comparers
|
||||
|
||||
## [15.0.0] - 2021-05-14
|
||||
### Added
|
||||
- Ported CsvReader for CF 3.5 compatibility from: https://github.com/tspence/csharp-csv-reader
|
||||
|
||||
@@ -38,10 +38,36 @@ namespace ICD.Common.Utils.Collections
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
public BiDictionary()
|
||||
public BiDictionary() :
|
||||
this(EqualityComparer<TKey>.Default, EqualityComparer<TValue>.Default)
|
||||
{
|
||||
m_KeyToValue = new Dictionary<TKey, TValue>();
|
||||
m_ValueToKey = new Dictionary<TValue, TKey>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="keyComparer"></param>
|
||||
/// <param name="valueComparer"></param>
|
||||
public BiDictionary(IEqualityComparer<TKey> keyComparer, IEqualityComparer<TValue> valueComparer)
|
||||
{
|
||||
m_KeyToValue = new Dictionary<TKey, TValue>(keyComparer);
|
||||
m_ValueToKey = new Dictionary<TValue, TKey>(valueComparer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="dict"></param>
|
||||
/// <param name="keyComparer"></param>
|
||||
/// <param name="valueComparer"></param>
|
||||
public BiDictionary([NotNull] Dictionary<TKey, TValue> dict, IEqualityComparer<TKey> keyComparer, IEqualityComparer<TValue> valueComparer)
|
||||
: this(keyComparer, valueComparer)
|
||||
{
|
||||
if (dict == null)
|
||||
throw new ArgumentNullException("dict");
|
||||
|
||||
foreach (KeyValuePair<TKey, TValue> kvp in dict)
|
||||
Add(kvp.Key, kvp.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -49,13 +75,8 @@ namespace ICD.Common.Utils.Collections
|
||||
/// </summary>
|
||||
/// <param name="dict"></param>
|
||||
public BiDictionary([NotNull] Dictionary<TKey, TValue> dict)
|
||||
: this()
|
||||
: this(dict, EqualityComparer<TKey>.Default, EqualityComparer<TValue>.Default)
|
||||
{
|
||||
if (dict == null)
|
||||
throw new ArgumentNullException("dict");
|
||||
|
||||
foreach (KeyValuePair<TKey, TValue> kvp in dict)
|
||||
Add(kvp.Key, kvp.Value);
|
||||
}
|
||||
|
||||
#region Methods
|
||||
|
||||
Reference in New Issue
Block a user