Exemplo n.º 1
0
        /// <summary>
        /// Compares the specified Object with the receiverd
        /// Returns true if and only if the specified Object is also an ArrayList of the same type, both Lists have the
        /// same Size, and all corresponding pairs of elements in the two Lists are identical.
        /// In other words, two Lists are defined to be equal if they contain the
        /// same elements in the same order.
        ///
        /// <summary>
        /// <param name="otherObj">the Object to be compared for equality with the receiver.</param>
        /// <returns>true if the specified Object is equal to the receiver.</returns>
        public override Boolean Equals(Object otherObj)
        { //delta
          // overridden for performance only.
            if (!(otherObj is DoubleArrayList))
            {
                return(base.Equals(otherObj));
            }
            if (this == otherObj)
            {
                return(true);
            }
            if (otherObj == null)
            {
                return(false);
            }
            DoubleArrayList other = (DoubleArrayList)otherObj;

            if (Size != other.Size)
            {
                return(false);
            }

            double[] theElements   = GetElements();
            double[] otherElements = other.ToArray();
            for (int i = Size; --i >= 0;)
            {
                if (theElements[i] != otherElements[i])
                {
                    return(false);
                }
            }
            return(true);
        }
        /// <summary>
        /// Compares the specified Object with the receiverd
        /// Returns true if and only if the specified Object is also an ArrayList of the same type, both Lists have the
        /// same Size, and all corresponding pairs of elements in the two Lists are identical.
        /// In other words, two Lists are defined to be equal if they contain the
        /// same elements in the same order.
        ///
        /// <summary>
        /// <param name="otherObj">the Object to be compared for equality with the receiver.</param>
        /// <returns>true if the specified Object is equal to the receiver.</returns>
        public override Boolean Equals(Object otherObj)
        { //delta
          // overridden for performance only.
            if ((otherObj is AbstractDoubleList))
            {
                return(base.Equals(otherObj));
            }
            if (this == otherObj)
            {
                return(true);
            }
            if (otherObj == null)
            {
                return(false);
            }

            double[] otherElements = null;

            if (otherObj is DoubleArrayList)
            {
                DoubleArrayList other = (DoubleArrayList)otherObj;
                if (Size != other.Size)
                {
                    return(false);
                }

                otherElements = other.ToArray();
            }
            else if (otherObj.IsList <Double>())
            {
                otherElements = ((List <Double>)otherObj).ToArray <Double>();
            }
            else if (otherObj.GetType().IsArray)
            {
                otherElements = (double[])otherObj;
            }

            if (otherElements != null)
            {
                double[] theElements = GetElements();
                for (int i = Size; --i >= 0;)
                {
                    if (theElements[i] != otherElements[i])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }