Exemplo 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
Exemplo 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);
        }
Exemplo 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));
        }
Exemplo 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);
            }
        }
Exemplo 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)
 );
Exemplo 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));
 }
Exemplo n.º 9
0
Arquivo: Pair.cs Projeto: 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
Exemplo 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);
        }
Exemplo 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);
 }
Exemplo n.º 12
0
Arquivo: Pair.cs Projeto: 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;
        }
Exemplo 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)
                 ));
        }
Exemplo n.º 14
0
        public bool Equals(Pair <T> pair)
        {
            if (pair == null)
            {
                return(false);
            }

            return(First.Equals(pair.First) && Second.Equals(pair.Second));
        }
Exemplo 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))));
 }
Exemplo n.º 16
0
 public bool Equals(Pair <T1, T2> other)
 {
     if (other == null)
     {
         return(false);
     }
     return(First.Equals(other.First) &&
            Second.Equals(other.Second));
 }
Exemplo 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;
 }
Exemplo 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));
            }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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);
        }
Exemplo 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)));
     }
 }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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)));
    }
Exemplo 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
 }
Exemplo 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));
    }
Exemplo 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)));
     }
 }
Exemplo 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));
        }