예제 #1
0
        /**
         * Determine if two lists are equal. Lists are equal if they have the same
         * arity and all of the elements are equal.
         *
         * @param o
         *            the list to compare to.
         *
         * @return true if the lists have the same arity and all the elements are
         *         equal.
         */
        public override bool Equals(Object o)
        {
            /*
             * Be careful to use methods even for "this", so that equals work also
             * for sublists
             */

            if (!(o is OtpErlangList))
            {
                return(false);
            }

            OtpErlangList l = (OtpErlangList)o;

            int a = arity();

            if (a != l.arity())
            {
                return(false);
            }
            for (int i = 0; i < a; i++)
            {
                if (!elementAt(i).Equals(l.elementAt(i)))
                {
                    return(false); // early exit
                }
            }
            OtpErlangObject otherTail = l.getLastTail();

            if (getLastTail() == null && otherTail == null)
            {
                return(true);
            }
            if (getLastTail() == null)
            {
                return(false);
            }
            return(getLastTail().Equals(l.getLastTail()));
        }
예제 #2
0
 public override OtpErlangObject elementAt(int i)
 {
     return(parent.elementAt(i + start));
 }