Esempio n. 1
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. 2
0
        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);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        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)
 );
Esempio n. 7
0
        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));
 }
Esempio n. 9
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. 10
0
        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);
        }
Esempio n. 11
0
 public override bool Equals(object obj)
 {
     if (obj is Pair <T, U> )
     {
         return(First.Equals(((Pair <T, U>)obj).First));
     }
     return(false);
 }
Esempio n. 12
0
File: Pair.cs Progetto: lunaxi7/XTMF
        }//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;
        }
Esempio n. 13
0
        /// <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)
                 ));
        }
Esempio n. 14
0
        public bool Equals(Pair <T> pair)
        {
            if (pair == null)
            {
                return(false);
            }

            return(First.Equals(pair.First) && Second.Equals(pair.Second));
        }
Esempio n. 15
0
 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))));
 }
Esempio n. 16
0
 public bool Equals(Pair <T1, T2> other)
 {
     if (other == null)
     {
         return(false);
     }
     return(First.Equals(other.First) &&
            Second.Equals(other.Second));
 }
Esempio n. 17
0
 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;
 }
Esempio n. 18
0
            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));
            }
Esempio n. 19
0
        /// <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));
        }
Esempio n. 20
0
        /// <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));
        }
Esempio n. 21
0
        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));
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
 /// <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)));
     }
 }
Esempio n. 24
0
        /// <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));
        }
Esempio n. 25
0
        /// <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));
        }
Esempio n. 26
0
    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)));
    }
Esempio n. 27
0
 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
 }
Esempio n. 28
0
    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));
    }
Esempio n. 29
0
 /// <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)));
     }
 }
Esempio n. 30
0
        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));
        }