public override int GetHashCode() { int hashFirst = First == null ? 0 : First.GetHashCode(); int hashSecond = Second == null ? 0 : Second.GetHashCode(); return(hashFirst ^ hashSecond); }
/// <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
public override int GetHashCode() { unchecked { return((First.GetHashCode() * 397) ^ Second.GetHashCode()); } }
/// <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
public override int GetHashCode() { unchecked { return(((First != null ? First.GetHashCode() : 0) * 397) ^ (Last != null ? Last.GetHashCode() : 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); } }
public override int GetHashCode() { int h0 = First?.GetHashCode() ?? 0; int h1 = Last?.GetHashCode() ?? 0; return(h0 ^ h1); }
public override int GetHashCode() { unchecked { return(First.GetHashCode() + Second.GetHashCode() + HashCode.Combine(Weight)); } }
public override int GetHashCode() { int hash = 17; hash *= (31 + First.GetHashCode()); hash *= (31 + Second.GetHashCode()); return(hash); }
/// <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); }
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); }
public override int GetHashCode() { int result; result = (First != null ? First.GetHashCode() : 0); result = 31 * result + (Second != null ? Second.GetHashCode() : 0); return(result); }
public override int GetHashCode() { var hashCode = 352033288; hashCode = hashCode * 1521134295 + First.GetHashCode(); hashCode = hashCode * 1521134295 + Last.GetHashCode(); return(hashCode); }
public override int GetHashCode() { return(unchecked ( 2 * First.GetHashCode() + 7 * Last.GetHashCode() + 11 * Page.GetHashCode() )); }
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); }
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); }
//hash code trait public override int GetHashCode() { unchecked { var hash = 0; hash = hash * 31 + First.GetHashCode(); hash = hash * 31 + Second.GetHashCode(); return(hash); } }
public override int GetHashCode() { var hash = 0; // Implement this however you like hash = First.GetHashCode() * 17 + Second.GetHashCode() + First.GetHashCode(); return(hash); }
/// <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); } }
public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 29 + First.GetHashCode(); hash = hash * 29 + Second.GetHashCode(); return(hash); } }
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); }
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()); }
/// <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 } }
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); } }
public override int GetHashCode() { unchecked { var hashCode = 13; hashCode = (hashCode * 397) ^ First.GetHashCode(); hashCode = (hashCode * 397) ^ Second.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = 0; hashCode = (hashCode * 397) ^ (First?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Last?.GetHashCode() ?? 0); return(hashCode); } }
public override int GetHashCode() { int hash = 33; unchecked { hash += 3 * First.GetHashCode() + 7 * Second.GetHashCode(); } return(hash); }
/// <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); }
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); }