private Node <T> Find(Node <T> current, T value) { bool clockwise = current.Equals(sentinel.Next); if (value.Equals(sentinel.Value)) { return(sentinel); } while (!current.Equals(sentinel)) { if (current.Value.Equals(value)) { return(current); } current = clockwise ? current.Next : current.Previous; } return(null); }
/// <summary> /// Checks if two LinkedLists are equal. /// </summary> /// <param name="list"></param> The list to check against. /// <returns></returns> True or false. public bool Equals(LinkedList <T> list) { if (this.Size() != list.Size()) { return(false); } Node <T> current1 = this.GetFirstNode(); Node <T> current2 = this.GetLastNode(); while (current1 != null) { if (!current1.Equals(current2)) { return(false); } current1 = current1.next; current2 = current2.next; } return(true); }