Exemple #1
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <param name="other">An object to compare with this object.</param>
 /// <returns>
 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 public bool Equals(TwoTupleKey <T, G> other)
 {
     if (other.First.GetHashCode() == _first.GetHashCode() &&
         other.Second.GetHashCode() == _second.GetHashCode())
     {
         return(true);
     }
     return(false);
 }
Exemple #2
0
        /// <summary>
        /// Compares the current object with another object of the same type.
        /// </summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>
        /// A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings:
        /// Value
        /// Meaning
        /// Less than zero
        /// This object is less than the <paramref name="other"/> parameter.
        /// Zero
        /// This object is equal to <paramref name="other"/>.
        /// Greater than zero
        /// This object is greater than <paramref name="other"/>.
        /// </returns>
        public int CompareTo(TwoTupleKey <T, G> other)
        {
            int otherFirst  = other.First.GetHashCode();
            int otherSecond = other.Second.GetHashCode();

            int first  = _first.GetHashCode();
            int second = _second.GetHashCode();

            if (first < otherFirst)
            {
                //Less than, this should always come before
                return(-1);
            }
            else if (first == otherFirst)
            {
                //Equal, need to check second value
                if (second < otherSecond)
                {
                    //Less than, this should always come before
                    return(-1);
                }
                else if (second == otherSecond)
                {
                    //All equal, return 0
                    return(0);
                }
                else
                {
                    //Greater than, this should always come after
                    return(1);
                }
            }
            else
            {
                //Greater than, this should always come after
                return(1);
            }
        }