コード例 #1
0
        public override bool Equals(object obj)
        {
            SingleLL that = (SingleLL)obj;

            if (IsEmpty() && that.IsEmpty())
            {
                return(true);
            }
            if (IsEmpty() || that.IsEmpty())
            {
                return(false);
            }

            Node currThis = root;
            Node currThat = that.root;

            while (currThis != null || currThat != null)
            {
                if (currThis == null)
                {
                    return(false);
                }
                if (currThat == null)
                {
                    return(false);
                }

                if (currThis.val != currThat.val)
                {
                    return(false);
                }

                currThis = currThis.next;
                currThat = currThat.next;
            }

            return(true);
        }
コード例 #2
0
 public static bool IsNullOrEmpty(SingleLL theList)
 {
     return(theList == null || theList.IsEmpty());
 }