/// <summary> /// Method to copy the data in this Sparse4DMatrix instance to another instance. /// </summary> /// <param name="sparse4DMatrix">An instance of the Sparse4DMatrix class.</param> public void CopyTo(Sparse4DMatrix <TKey0, TKey1, TKey2, TKey3, TValue> sparse4DMatrix) { sparse4DMatrix.m_dictionary.Clear(); // Copy each key value pair to the dictionary. foreach (KeyValuePair <ComparableTuple4 <TKey0, TKey1, TKey2, TKey3>, TValue> pair in m_dictionary) { ComparableTuple4 <TKey0, TKey1, TKey2, TKey3> newCombinedKey = new ComparableTuple4 <TKey0, TKey1, TKey2, TKey3>(pair.Key); sparse4DMatrix.m_dictionary.Add(newCombinedKey, pair.Value); } }
/// <summary> /// Method to copy the data in another Sparse4DMatrix instance to this instance. /// </summary> /// <param name="sparse4DMatrix">An instance of the Sparse4DMatrix class.</param> private void Initialize(Sparse4DMatrix <TKey0, TKey1, TKey2, TKey3, TValue> sparse4DMatrix) { m_dictionary.Clear(); // Copy each key value pair to the dictionary. foreach (KeyValuePair <ComparableTuple4 <TKey0, TKey1, TKey2, TKey3>, TValue> pair in sparse4DMatrix) { ComparableTuple4 <TKey0, TKey1, TKey2, TKey3> newCombinedKey = new ComparableTuple4 <TKey0, TKey1, TKey2, TKey3>(pair.Key); m_dictionary.Add(newCombinedKey, pair.Value); } }
/// <summary> /// Copy constructor. /// </summary> /// <param name="sparse4DMatrix">The sparse array instance to be copied</param> public Sparse4DMatrix(Sparse4DMatrix <TKey0, TKey1, TKey2, TKey3, TValue> sparse4DMatrix) { InitializeDictionary(); Initialize(sparse4DMatrix); DefaultValue = sparse4DMatrix.DefaultValue; }