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); }
public static bool IsNullOrEmpty(SingleLL theList) { return(theList == null || theList.IsEmpty()); }