Beispiel #1
0
 /// IEqualityComparer.Equals compares the items in this group for equality.
 public bool Equals(ComparableTuple3 <TItem0, TItem1, TItem2> groupA,
                    ComparableTuple3 <TItem0, TItem1, TItem2> groupB)
 {
     return((groupA.Item0.Equals(groupB.Item0)) &&
            (groupA.Item1.Equals(groupB.Item1)) &&
            (groupA.Item2.Equals(groupB.Item2)));
 }
Beispiel #2
0
 /// <summary>
 /// This method must be overridden by the caller to separate a combined key into the two original keys.
 /// </summary>
 /// <param name="combinedKey">A value that combines the keys in a unique fashion</param>
 /// <param name="key0">A reference to the first key</param>
 /// <param name="key1">A reference to the second key</param>
 /// <param name="key2">A reference to the third key</param>
 public void SeparateCombinedKeys(ComparableTuple3 <TKey0, TKey1, TKey2> combinedKey,
                                  ref TKey0 key0,
                                  ref TKey1 key1,
                                  ref TKey2 key2)
 {
     key0 = combinedKey.Item0;
     key1 = combinedKey.Item1;
     key2 = combinedKey.Item2;
 }
Beispiel #3
0
        /// <summary>
        /// Returns a hash code for an object.
        /// </summary>
        /// <param name="obj">An object of type ComparableTuple3</param>
        /// <returns>A hash code for the object.</returns>
        public int GetHashCode(ComparableTuple3 <TItem0, TItem1, TItem2> group)
        {
            int hash0 = group.Item0.GetHashCode();
            int hash1 = group.Item1.GetHashCode();
            int hash2 = group.Item2.GetHashCode();

            int hash = 577 * hash0 + 599 * hash1 + 619 * hash2;

            return(hash.GetHashCode());
        }
Beispiel #4
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);
            }
        }
Beispiel #5
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);
            }
        }
Beispiel #6
0
        /// <summary>
        /// This methods implements the IComparable<ComparableTuple3<TItem0, TItem1, TItem2>> interface.
        /// </summary>
        /// <param name="group">The group being compared to this group</param>
        /// <returns>
        /// The value -1 if this groups is less than the passed group.
        /// The value 1 if this group is greater than the passed group.
        /// The value 0 if this group and the passed groups are equal.
        /// </returns>
        public int CompareTo(ComparableTuple3 <TItem0, TItem1, TItem2> group)
        {
            int result = this.Item0.CompareTo(group.Item0);

            if (result == 0)
            {
                result = this.Item1.CompareTo(group.Item1);

                if (result == 0)
                {
                    result = this.Item2.CompareTo(group.Item2);
                }
            }

            return(result);
        }
Beispiel #7
0
 /// <summary>
 /// Constructs a new instance with the same item values as this instance.
 /// </summary>
 /// <param name="group">The group used to initialize this instance</param>
 public ComparableTuple3(ComparableTuple3 <TItem0, TItem1, TItem2> group)
 {
     Item0 = group.Item0;
     Item1 = group.Item1;
     Item2 = group.Item2;
 }