From 131e2f87f42ecfa9c0b95231ff85888fb24c9ff7 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Thu, 21 Feb 2019 14:04:06 -0500 Subject: [PATCH] feat: Adding constructor to BiDictionary to build from an existing dict --- ICD.Common.Utils/Collections/BiDictionary.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ICD.Common.Utils/Collections/BiDictionary.cs b/ICD.Common.Utils/Collections/BiDictionary.cs index d30326a..3467d01 100644 --- a/ICD.Common.Utils/Collections/BiDictionary.cs +++ b/ICD.Common.Utils/Collections/BiDictionary.cs @@ -30,9 +30,24 @@ namespace ICD.Common.Utils.Collections /// Constructor. /// public BiDictionary() + : this(null) + { + } + + /// + /// Constructor. + /// + /// + public BiDictionary(Dictionary dict) { m_KeyToValue = new Dictionary(); m_ValueToKey = new Dictionary(); + + if (dict == null) + return; + + foreach (KeyValuePair kvp in dict) + Add(kvp.Key, kvp.Value); } #region Methods