/// <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 ComparableTuple8(ComparableTuple8 <TItem0, TItem1, TItem2, TItem3, TItem4, TItem5, TItem6, TItem7> group)
 {
     Item0 = group.Item0;
     Item1 = group.Item1;
     Item2 = group.Item2;
     Item3 = group.Item3;
     Item4 = group.Item4;
     Item5 = group.Item5;
     Item6 = group.Item6;
     Item7 = group.Item7;
 }
 /// IEqualityComparer.Equals compares the items in this group for equality.
 public bool Equals(ComparableTuple8 <TItem0, TItem1, TItem2, TItem3, TItem4, TItem5, TItem6, TItem7> groupA,
                    ComparableTuple8 <TItem0, TItem1, TItem2, TItem3, TItem4, TItem5, TItem6, TItem7> groupB)
 {
     return((groupA.Item0.Equals(groupB.Item0)) &&
            (groupA.Item1.Equals(groupB.Item1)) &&
            (groupA.Item2.Equals(groupB.Item2)) &&
            (groupA.Item3.Equals(groupB.Item3)) &&
            (groupA.Item4.Equals(groupB.Item4)) &&
            (groupA.Item5.Equals(groupB.Item5)) &&
            (groupA.Item6.Equals(groupB.Item6)) &&
            (groupA.Item7.Equals(groupB.Item7)));
 }
        /// <summary>
        /// Returns a hash code for an object.
        /// </summary>
        /// <param name="obj">An object of type ComparableTuple8</param>
        /// <returns>A hash code for the object.</returns>
        public int GetHashCode(ComparableTuple8 <TItem0, TItem1, TItem2, TItem3, TItem4, TItem5, TItem6, TItem7> group)
        {
            int hash0 = group.Item0.GetHashCode();
            int hash1 = group.Item1.GetHashCode();
            int hash2 = group.Item2.GetHashCode();
            int hash3 = group.Item3.GetHashCode();
            int hash4 = group.Item4.GetHashCode();
            int hash5 = group.Item5.GetHashCode();
            int hash6 = group.Item6.GetHashCode();
            int hash7 = group.Item7.GetHashCode();

            int hash = 577 * hash0 + 599 * hash1 + 619 * hash2 + 661 * hash3
                       + 743 * hash4 + 829 * hash5 + 971 * hash6 + 1117 * hash7;

            return(hash.GetHashCode());
        }
Beispiel #4
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>
 /// <param name="key3">A reference to the fourth key</param>
 /// <param name="key4">A reference to the fifth key</param>
 /// <param name="key5">A reference to the sixth key</param>
 /// <param name="key6">A reference to the seventh key</param>
 /// <param name="key7">A reference to the eighth key</param>
 public void SeparateCombinedKeys(ComparableTuple8 <TKey0, TKey1, TKey2, TKey3, TKey4, TKey5, TKey6, TKey7> combinedKey,
                                  ref TKey0 key0,
                                  ref TKey1 key1,
                                  ref TKey2 key2,
                                  ref TKey3 key3,
                                  ref TKey4 key4,
                                  ref TKey5 key5,
                                  ref TKey6 key6,
                                  ref TKey7 key7)
 {
     key0 = combinedKey.Item0;
     key1 = combinedKey.Item1;
     key2 = combinedKey.Item2;
     key3 = combinedKey.Item3;
     key4 = combinedKey.Item4;
     key5 = combinedKey.Item5;
     key6 = combinedKey.Item6;
     key7 = combinedKey.Item7;
 }
        /// <summary>
        /// This methods implements the IComparable<ComparableTuple8<TItem0, TItem1, TItem2, TItem3, TItem4, TItem5, TItem6, TItem7>> 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(ComparableTuple8 <TItem0, TItem1, TItem2, TItem3, TItem4, TItem5, TItem6, TItem7> 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);

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

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

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

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

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

            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// Method to copy the data in this Sparse8DMatrix instance to another instance.
        /// </summary>
        /// <param name="sparse8DMatrix">An instance of the Sparse8DMatrix class.</param>
        public void CopyTo(Sparse8DMatrix <TKey0, TKey1, TKey2, TKey3, TKey4, TKey5, TKey6, TKey7, TValue> sparse8DMatrix)
        {
            sparse8DMatrix.m_dictionary.Clear();

            // Copy each key value pair to the dictionary.
            foreach (KeyValuePair <ComparableTuple8 <TKey0, TKey1, TKey2, TKey3, TKey4, TKey5, TKey6, TKey7>, TValue> pair in m_dictionary)
            {
                ComparableTuple8 <TKey0, TKey1, TKey2, TKey3, TKey4, TKey5, TKey6, TKey7> newCombinedKey = new ComparableTuple8 <TKey0, TKey1, TKey2, TKey3, TKey4, TKey5, TKey6, TKey7>(pair.Key);
                sparse8DMatrix.m_dictionary.Add(newCombinedKey, pair.Value);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Method to copy the data in another Sparse8DMatrix instance to this instance.
        /// </summary>
        /// <param name="sparse8DMatrix">An instance of the Sparse8DMatrix class.</param>
        private void Initialize(Sparse8DMatrix <TKey0, TKey1, TKey2, TKey3, TKey4, TKey5, TKey6, TKey7, TValue> sparse8DMatrix)
        {
            m_dictionary.Clear();

            // Copy each key value pair to the dictionary.
            foreach (KeyValuePair <ComparableTuple8 <TKey0, TKey1, TKey2, TKey3, TKey4, TKey5, TKey6, TKey7>, TValue> pair in sparse8DMatrix)
            {
                ComparableTuple8 <TKey0, TKey1, TKey2, TKey3, TKey4, TKey5, TKey6, TKey7> newCombinedKey = new ComparableTuple8 <TKey0, TKey1, TKey2, TKey3, TKey4, TKey5, TKey6, TKey7>(pair.Key);
                m_dictionary.Add(newCombinedKey, pair.Value);
            }
        }