Esempio n. 1
0
        public override int GetHashCode()
        {
            int hashFirst  = First == null ? 0 : First.GetHashCode();
            int hashSecond = Second == null ? 0 : Second.GetHashCode();

            return(hashFirst ^ hashSecond);
        }
Esempio n. 2
0
 /// <summary>
 /// Attempts to compair, F then S and in the last case it trys to compare hashcodes
 /// </summary>
 /// <param name="other">The pair we want to compare with</param>
 /// <returns>Less than zero if it is less, 0 if equal, otherwise greater than zero</returns>
 public int CompareTo(Pair<F, S> other)
 {
     IComparable<F> compFirst = First as IComparable<F>;
     IComparable<S> compSecond = Second as IComparable<S>;
     // if they are both comparible then we will just see if they are both equal, if not -1
     if ( compFirst != null & compSecond != null )
     {
         int value;
         return ( ( value = compFirst.CompareTo( other.First ) ) == 0 ) ? ( ( ( value = compSecond.CompareTo( other.Second ) ) == 0 ) ? 0 : value ) : value;
     }
     // try to compare the first value
     if ( compFirst != null )
     {
         int res = compFirst.CompareTo( other.First );
         // if we were equal,if we can compair the second, do that
         res = res == 0 ? ( compSecond != null ? compSecond.CompareTo( Second ) : 0 ) : 0;
         return res;
     }
     // if not, try the second
     if ( compSecond != null )
     {
         return compSecond.CompareTo( other.Second );
     }
     //see if they are equal
     if ( First.Equals( other.First ) && Second.Equals( other.Second ) )
     {
         return 0;
     }
     // if they are not equal, subract the total of the hashcodes, this can cause false equals
     return First.GetHashCode() + Second.GetHashCode() - other.First.GetHashCode() - other.Second.GetHashCode();
 }//end CompareTo
Esempio n. 3
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((First.GetHashCode() * 397) ^ Second.GetHashCode());
     }
 }
Esempio n. 4
0
File: Pair.cs Progetto: lunaxi7/XTMF
 /// <summary>
 /// Attempts to compare, F then S and in the last case it tries to compare hashcodes
 /// </summary>
 /// <param name="other">The pair we want to compare with</param>
 /// <returns>Less than zero if it is less, 0 if equal, otherwise greater than zero</returns>
 public int CompareTo(Pair<TF, TS> other)
 {
     var compFirst = First as IComparable<TF>;
     var compSecond = Second as IComparable<TS>;
     // if they are both comparable then we will just see if they are both equal, if not -1
     if ( compFirst != null & compSecond != null )
     {
         int value;
         return ( ( value = compFirst.CompareTo( other.First ) ) == 0 ) ? ( ( ( value = compSecond.CompareTo( other.Second ) ) == 0 ) ? 0 : value ) : value;
     }
     // try to compare the first value
     if ( compFirst != null )
     {
         var res = compFirst.CompareTo( other.First );
         // second is always null at this point
         return res;
     }
     // if not, try the second
     if ( compSecond != null )
     {
         return compSecond.CompareTo( other.Second );
     }
     //see if they are equal
     if ( First.Equals( other.First ) && Second.Equals( other.Second ) )
     {
         return 0;
     }
     // if they are not equal, subtract the total of the hashcodes, this can cause false equals
     return First.GetHashCode() + Second.GetHashCode() - other.First.GetHashCode() - other.Second.GetHashCode();
 }//end CompareTo
Esempio n. 5
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((First != null ? First.GetHashCode() : 0) * 397) ^ (Last != null ? Last.GetHashCode() : 0));
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Self != null)
         {
             hashCode = hashCode * 59 + Self.GetHashCode();
         }
         if (First != null)
         {
             hashCode = hashCode * 59 + First.GetHashCode();
         }
         if (Prev != null)
         {
             hashCode = hashCode * 59 + Prev.GetHashCode();
         }
         if (Next != null)
         {
             hashCode = hashCode * 59 + Next.GetHashCode();
         }
         if (Last != null)
         {
             hashCode = hashCode * 59 + Last.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 7
0
        public override int GetHashCode()
        {
            int h0 = First?.GetHashCode() ?? 0;
            int h1 = Last?.GetHashCode() ?? 0;

            return(h0 ^ h1);
        }
Esempio n. 8
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(First.GetHashCode() + Second.GetHashCode() + HashCode.Combine(Weight));
     }
 }
Esempio n. 9
0
        public override int GetHashCode()
        {
            int hash = 17;

            hash *= (31 + First.GetHashCode());
            hash *= (31 + Second.GetHashCode());
            return(hash);
        }
Esempio n. 10
0
        /// <summary>
        ///     Returns a hash code for the pair, suitable for use in a hash-table or other hashed collection.
        ///     Two pairs that compare equal (using Equals) will have the same hash code. The hash code for
        ///     the pair is derived by combining the hash codes for each of the two elements of the pair.
        /// </summary>
        /// <returns>The hash code.</returns>
        public override int GetHashCode()
        {
            // Build the hash code from the hash codes of First and Second.
            var hashFirst  = First == null ? 0x61E04917 : First.GetHashCode();
            var hashSecond = Second == null ? 0x198ED6A3 : Second.GetHashCode();

            return(hashFirst ^ hashSecond);
        }
Esempio n. 11
0
        public override int GetHashCode()
        {
            // same with Tuple.CombineHashCodess
            var hash1 = First?.GetHashCode() ?? 0;
            var hash2 = Second?.GetHashCode() ?? 0;

            return((hash1 << 5) + hash1 ^ hash2);
        }
        public override int GetHashCode()
        {
            int firstHash = First != null?First.GetHashCode() : 0;

            int secondHash = Second != null?Second.GetHashCode() : 0;

            return((firstHash + secondHash) * secondHash + firstHash);
        }
Esempio n. 13
0
        public override int GetHashCode()
        {
            int result;

            result = (First != null ? First.GetHashCode() : 0);
            result = 31 * result + (Second != null ? Second.GetHashCode() : 0);
            return(result);
        }
Esempio n. 14
0
        public override int GetHashCode()
        {
            var hashCode = 352033288;

            hashCode = hashCode * 1521134295 + First.GetHashCode();
            hashCode = hashCode * 1521134295 + Last.GetHashCode();
            return(hashCode);
        }
Esempio n. 15
0
 public override int GetHashCode()
 {
     return(unchecked (
                2 * First.GetHashCode() +
                7 * Last.GetHashCode() +
                11 * Page.GetHashCode()
                ));
 }
Esempio n. 16
0
    public override int GetHashCode()
    {
        int hash = 17;

        // Suitable nullity checks etc, of course :)
        hash = hash * 23 + First.GetHashCode();
        hash = hash * 23 + Second.GetHashCode();
        return(hash);
    }
Esempio n. 17
0
        public override int GetHashCode()
        {
            int prime  = 31;
            int result = 1;

            result = prime * result + (First == null ? 0 : First.GetHashCode());
            result = prime * result + (Second == null ? 0 : Second.GetHashCode());
            return(result);
        }
Esempio n. 18
0
 //hash code trait
 public override int GetHashCode()
 {
     unchecked {
         var hash = 0;
         hash = hash * 31 + First.GetHashCode();
         hash = hash * 31 + Second.GetHashCode();
         return(hash);
     }
 }
Esempio n. 19
0
        public override int GetHashCode()
        {
            var hash = 0;

            // Implement this however you like
            hash = First.GetHashCode() * 17 + Second.GetHashCode() + First.GetHashCode();

            return(hash);
        }
Esempio n. 20
0
 /// <summary>
 /// Override of the <see cref="Object.GetHashCode"/> Method.
 /// </summary>
 /// <returns>A Hash-Code suitable for use in hashtables.</returns>
 /// <remarks>Only considers the First, Middle, and Last names; ignores other fields.</remarks>
 public override int GetHashCode()
 {
     unchecked {
         int hash = 17;
         hash = hash * 23 + (First.HasValue() ? First.GetHashCode() : 0);
         hash = hash * 23 + (Last.HasValue() ? Last.GetHashCode() : 0);
         hash = hash * 23 + (Middle.HasValue() ? Middle.GetHashCode() : 0);
         return(hash);
     }
 }
Esempio n. 21
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 29 + First.GetHashCode();
         hash = hash * 29 + Second.GetHashCode();
         return(hash);
     }
 }
Esempio n. 22
0
        public override int GetHashCode()
        {
            var hashCode = 1852591177;

            hashCode = hashCode * -1521134295 + x.GetHashCode();
            hashCode = hashCode * -1521134295 + y.GetHashCode();
            hashCode = hashCode * -1521134295 + First.GetHashCode();
            hashCode = hashCode * -1521134295 + Second.GetHashCode();
            return(hashCode);
        }
Esempio n. 23
0
        public override int GetHashCode()
        {
            var a = First.GetHashCode();
            var c = Third.GetHashCode();

            var ab = ((a << 5) + a) ^ Second.GetHashCode();
            var cd = ((c << 5) + a) ^ Third.GetHashCode();

            return(((ab << 5) + ab) ^ cd.GetHashCode());
        }
Esempio n. 24
0
        /// <summary>
        /// Gets a hash code for this pair.
        /// </summary>
        /// <returns>A 32-bit signed integer hash code.</returns>
        /// <remarks>Warning, this function will box value types. If you need high-performance code, create a special
        /// type just for the two types you're putting together.</remarks>
        public override int GetHashCode()
        {
            int hashOfFirst  = ReferenceEquals(First, null) ? 0 : First.GetHashCode();
            int hashOfSecond = ReferenceEquals(Second, null) ? 0 : Second.GetHashCode();

            unchecked
            {
                return(37 + 23 * (hashOfFirst + (23 * hashOfSecond)));                    // So (x, y) and (y, x) have different hashes
            }
        }
Esempio n. 25
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Element.GetHashCode();
         hashCode = (hashCode * 397) ^ (Super != null ? Super.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (First != null ? First.GetHashCode() : 0);
         return(hashCode);
     }
 }
Esempio n. 26
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = 13;
         hashCode = (hashCode * 397) ^ First.GetHashCode();
         hashCode = (hashCode * 397) ^ Second.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 27
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = 0;
         hashCode = (hashCode * 397) ^ (First?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Last?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Esempio n. 28
0
        public override int GetHashCode()
        {
            int hash = 33;

            unchecked
            {
                hash += 3 * First.GetHashCode() + 7 * Second.GetHashCode();
            }

            return(hash);
        }
Esempio n. 29
0
        /// <summary>
        /// Returns the hashcode for the object.
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            int result = First == null ? 0 : First.GetHashCode();

            unchecked {
                result  = result << 8;
                result += Second == null ? 0 : Second.GetHashCode();
            }

            return(result);
        }
Esempio n. 30
0
        public override int GetHashCode()
        {
            const int hashSeed       = 7;
            const int hashMultiplier = 13;

            var hash = hashSeed;

            hash = (hash * hashMultiplier) ^ First.GetHashCode();
            hash = (hash * hashMultiplier) ^ Second.GetHashCode();

            return(hash);
        }