예제 #1
0
        /// <summary>
        /// Method to copy the data in this Sparse3DMatrix instance to another instance.
        /// </summary>
        /// <param name="sparse3DMatrix">An instance of the Sparse3DMatrix class.</param>
        public void CopyTo(Sparse3DMatrix <TKey0, TKey1, TKey2, TValue> sparse3DMatrix)
        {
            sparse3DMatrix.m_dictionary.Clear();

            // Copy each key value pair to the dictionary.
            foreach (KeyValuePair <ComparableTuple3 <TKey0, TKey1, TKey2>, TValue> pair in m_dictionary)
            {
                ComparableTuple3 <TKey0, TKey1, TKey2> newCombinedKey = new ComparableTuple3 <TKey0, TKey1, TKey2>(pair.Key);
                sparse3DMatrix.m_dictionary.Add(newCombinedKey, pair.Value);
            }
        }
예제 #2
0
        /// <summary>
        /// Method to copy the data in another Sparse3DMatrix instance to this instance.
        /// </summary>
        /// <param name="sparse3DMatrix">An instance of the Sparse3DMatrix class.</param>
        private void Initialize(Sparse3DMatrix <TKey0, TKey1, TKey2, TValue> sparse3DMatrix)
        {
            m_dictionary.Clear();

            // Copy each key value pair to the dictionary.
            foreach (KeyValuePair <ComparableTuple3 <TKey0, TKey1, TKey2>, TValue> pair in sparse3DMatrix)
            {
                ComparableTuple3 <TKey0, TKey1, TKey2> newCombinedKey = new ComparableTuple3 <TKey0, TKey1, TKey2>(pair.Key);
                m_dictionary.Add(newCombinedKey, pair.Value);
            }
        }
예제 #3
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="sparse3DMatrix">The sparse array instance to be copied</param>
 public Sparse3DMatrix(Sparse3DMatrix <TKey0, TKey1, TKey2, TValue> sparse3DMatrix)
 {
     InitializeDictionary();
     Initialize(sparse3DMatrix);
     DefaultValue = sparse3DMatrix.DefaultValue;
 }