public void Delete(T value) { SimpleNode <T> temp = _head; if (_head == null) { return; } do { if (temp.GetValue().Equals(value)) { if (temp == _head) { if (Length() == 1) { _head = null; } } temp.SetValue(temp.GetNext().GetValue()); if (temp.GetNext() == _head) { _head = temp; } temp.SetNext(temp.GetNext().GetNext()); break; } temp = temp.GetNext(); }while(temp != _head); }
public void Append(T value) { if (_head == null) { _head = new SimpleNode <T>(value); _head.SetNext(_head); return; } T headCopy = _head.GetValue(); SimpleNode <T> headNextCopy = _head.GetNext(); _head.SetValue(value); SimpleNode <T> insert = new SimpleNode <T>(headCopy); _head.SetNext(insert); insert.SetNext(headNextCopy); _head = insert; }