/// <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 bool equals(Object o) { if (this == o) { return(true); } if (!(o is Triple <T1, T2, T3>)) { return(false); } Triple <T1, T2, T3> triple = (Triple <T1, T2, T3>)o; if (First != null ? !First.Equals(triple.First) : triple.First != null) { return(false); } if (Second != null ? !Second.Equals(triple.Second) : triple.Second != null) { return(false); } if (Third != null ? !Third.Equals(triple.Third) : triple.Third != null) { return(false); } return(true); }
public override bool Equals(object obj) { if (this == obj) { return(true); } LinkedList1 <T> other = obj as LinkedList1 <T>; if (null == other) { return(false); } if (!First.Equals(other.First)) { return(false); } if (null == RestOrNull) { return(null == other.RestOrNull); } return(RestOrNull.Equals(other.RestOrNull)); }
private Node PreviousNode(Node node) { if (First.Equals(node)) { return(node); } else { Node result = First; for (int i = 0; i < Count; i++) { if ((result.Next).Equals(node)) { return(result); } else { result = result.Next; } } return(result); } }
public void Remove(ListNode <T> node) { if (node == null) { throw new ArgumentException("Node to delete cannot be null."); } if (!this.Equals(node.List)) { throw new ArgumentException("Node to delete must be from the list, on which operation was invoked."); } if (First.Equals(node)) { RemoveFirst(); } else if (Last.Equals(node)) { RemoveLast(); } else { RemoveElement(node); } }
/// <summary> /// Check Name equality. /// </summary> /// <param name="name"></param> /// <returns></returns> public bool Equals(Name name) => name == null ? false : Suffix.Equals(name.Suffix) && ( ReferenceEquals(this.Suffix, name.Suffix) || Suffix != null && Suffix.Equals(name.Suffix) ) && ( ReferenceEquals(this.First, name.First) || First != null && First.Equals(name.First) ) && ( ReferenceEquals(this.Middle, name.Middle) || Middle != null && Middle.Equals(name.Middle) ) && ( ReferenceEquals(this.Last, name.Last) || Last != null && Last.Equals(name.Last) ) && ( ReferenceEquals(this.Prefix, name.Prefix) || Prefix != null && Prefix.Equals(name.Prefix) ) && ( ReferenceEquals(this.IsOrganization, name.IsOrganization) || IsOrganization.Equals(name.IsOrganization) );
public void RemoveAt(int index) { if (index < 0 || index >= Length) { return; } LLNode <T> node = this[index]; if (node.PrevNode != null) { node.PrevNode.NextNode = node.NextNode; } if (node.NextNode != null) { node.NextNode.PrevNode = node.PrevNode; } if (Last.Equals(node)) { Last = node.PrevNode; } else if (First.Equals(node)) { First = node.NextNode; } Length--; }
public bool Equals(IName other) { return(First.Equals(other.First, StringComparison.CurrentCultureIgnoreCase) && Middle.Equals(other.Middle, StringComparison.CurrentCultureIgnoreCase) && Last.Equals(other.Last, StringComparison.CurrentCultureIgnoreCase) && Gender.Equals(other.Gender)); }
/// <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 bool Equals(Couple <T> couple) { bool result = (couple != null); result = (!result) ? false : (First != null && couple.First != null && First.Equals(couple.First)) || (null == First && null == couple.First); result = (!result) ? false : (Second != null && couple.Second != null && Second.Equals(couple.Second)) || (null == Second && null == couple.Second); return(result); }
public override bool Equals(object obj) { if (obj is Pair <T, U> ) { return(First.Equals(((Pair <T, U>)obj).First)); } return(false); }
}//end CompareTo public override bool Equals(object obj) { if (obj is Pair<TF, TS> other) { return (First.Equals(other.First)) && (Second.Equals(other.Second)); } return false; }
/// <summary> /// Returns true if Name instances are equal /// </summary> /// <param name="other">Instance of Name to be compared</param> /// <returns>Boolean</returns> public bool Equals(Name other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Uuid == other.Uuid || Uuid != null && Uuid.Equals(other.Uuid) ) && ( Alias == other.Alias || Alias != null && Alias.Equals(other.Alias) ) && ( First == other.First || First != null && First.Equals(other.First) ) && ( Family == other.Family || Family != null && Family.Equals(other.Family) ) && ( Given == other.Given || Given != null && Given.SequenceEqual(other.Given) ) && ( Prefix == other.Prefix || Prefix != null && Prefix.SequenceEqual(other.Prefix) ) && ( Suffix == other.Suffix || Suffix != null && Suffix.SequenceEqual(other.Suffix) ) && ( Creation == other.Creation || Creation != null && Creation.Equals(other.Creation) ) && ( LastUpdated == other.LastUpdated || LastUpdated != null && LastUpdated.Equals(other.LastUpdated) )); }
public bool Equals(Pair <T> pair) { if (pair == null) { return(false); } return(First.Equals(pair.First) && Second.Equals(pair.Second)); }
public bool Equals(StructTuple <TFirst, TSecond> obj) { return(((First == null) == (obj.First == null)) && (First == null ? true : (ReferenceEquals(First, obj.First) || First.Equals(obj.First))) && ((Second == null) == (obj.Second == null)) && (Second == null ? true : (ReferenceEquals(Second, obj.Second) || Second.Equals(obj.Second)))); }
public bool Equals(Pair <T1, T2> other) { if (other == null) { return(false); } return(First.Equals(other.First) && Second.Equals(other.Second)); }
public override bool Equals(Object o) { if (o is Triplet<X, Y, Z>) { Triplet<X, Y, Z> other = (Triplet<X, Y, Z>)o; return (First.Equals(other.First)) && (Second.Equals(other.Second)) && (Third.Equals(other.Third)); } return false; }
public override bool Equals(object obj) { var pair = obj as Pair <T1, T2>; if (object.ReferenceEquals(pair, null)) { return(false); } return(First.Equals(pair.First) && Second.Equals(pair.Second)); }
/// <summary> /// 是否相等 /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (!(obj is Triple <T>)) { return(false); } var o = obj as Triple <T>; return(First.Equals(o.First) && Second.Equals(o.Second) && Third.Equals(o.Third)); }
/// <summary> /// 是否相等 /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (!(obj is Pair <T>)) { return(false); } var o = obj as Pair <T>; return(First.Equals(o.First) && Second.Equals(o.Second)); }
public override bool Equals(object obj) { Tuple <T1, T2> tup = obj as Tuple <T1, T2>; if (tup == null) { return(false); } return(First.Equals(tup.First) && Second.Equals(tup.Second)); }
public override bool Equals(object obj) { if (obj is UnorderedPair <FirstType, SecondType> ) { Pair <FirstType, SecondType> pair = (Pair <FirstType, SecondType>)obj; return((First.Equals(pair.First) && Second.Equals(pair.Second)) || (First.Equals(pair.Second) && Second.Equals(pair.First))); } return(false); }
/// <summary></summary> /// <param name=""></param> /// <param name=""></param> public static bool operator !=(Property First, Property Second) { if (((object)First) == null || ((object)Second) == null) { return(!Equals(First, Second)); } else { return(!(First.Equals(Second))); } }
/// <summary> /// Determines whether the specified <see cref="System.Object"/> is equal to this instance. /// </summary> /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>. /// </returns> public override bool Equals(object obj) { if (obj == null) { return(false); } var target = (FirstSecondPair <TFirst, TSecond>)obj; return(First.Equals(target.First) && Second.Equals(target.Second)); }
/// <summary> /// Two UOPairs are equal if their (sorted) elements are equal. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (!(obj is UOPair <T>)) { return(false); } UOPair <T> other = (UOPair <T>)obj; return(First.Equals(other.First) && Second.Equals(other.Second)); }
public bool Equals(Tuple <T1, T2> p) { // If parameter is null return false: if ((object)p == null) { return(false); } // Return true if the fields match: return((First.Equals(p.First)) && (Second.Equals(p.Second))); }
public bool Equals(Pair <T, U> other) { // ReSharper disable CompareNonConstrainedGenericWithNull return ((((First == null) && (other.First == null)) || ((First != null) && First.Equals(other.First))) && (((Second == null) && (other.Second == null)) || ((Second != null) && Second.Equals(other.Second)))); // ReSharper restore CompareNonConstrainedGenericWithNull }
public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } Pair <T1, T2> other = (Pair <T1, T2>)obj; return(First.Equals(other.First) && Second.Equals(other.Second)); }
/// <summary></summary> /// <param name=""></param> /// <param name=""></param> public static bool operator !=(DecimalInt First, DecimalInt Second) { if (((object)First) == null || ((object)Second) == null) { return(!Equals(First, Second)); } else { return(!(First.Equals(Second))); } }
public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } var other = (CalendarRange)obj; return(First.Equals(other.First) && Last.Equals(other.Last)); }