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 SimpleNode <T> Pop() { if (_head == null) { return(null); } SimpleNode <T> popped = _head; _head = _head.GetNext(); return(popped); }
public int Size() { SimpleNode <T> temp = _head; int result = 0; while (temp != null) { result++; temp = temp.GetNext(); } return(result); }
public int Size() { SimpleNode <T> current = _head; int result = 0; while (current != null) { result++; current = current.GetNext(); } return(result); }
public void Delete(T value) { SimpleNode <T> temp = _head; SimpleNode <T> prev = null; while (temp != null) { if (temp.GetValue().Equals(value)) { if (temp == _head) { _head = temp.GetNext(); } else { prev.SetNext(temp.GetNext()); } break; } prev = temp; temp = temp.GetNext(); } }
public SimpleNode <T> Search(T value) { SimpleNode <T> temp = _head; while (temp != null) { if (temp.GetValue().Equals(value)) { break; } temp = temp.GetNext(); } return(temp); }
public SimpleNode <T> Peak() { if (_head == null) { return(null); } SimpleNode <T> temp = _head; while (temp.HasNext()) { temp = temp.GetNext(); } return(temp); }
public void Append(T value) { if (_head == null) { _head = new SimpleNode <T>(value); return; } SimpleNode <T> temp = _head; while (temp.HasNext()) { temp = temp.GetNext(); } temp.SetNext(new SimpleNode <T>(value)); }
public int Length() { SimpleNode <T> temp = _head; if (temp == null) { return(0); } int result = 0; do { result++; temp = temp.GetNext(); }while (temp != _head); return(result); }
public SimpleNode <T> Search(T value) { SimpleNode <T> temp = _head; if (_head == null) { return(null); } do { if (temp.GetValue().Equals(value)) { return(temp); } temp = temp.GetNext(); }while(temp != _head); return(null); }
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; }
public SimpleNode <T> Dequeue() { if (_head == null) { return(null); } SimpleNode <T> temp = _head; SimpleNode <T> prev = null; while (temp.HasNext()) { prev = temp; temp = temp.GetNext(); } if (prev == null) { Clear(); return(temp); } prev.SetNext(null); return(temp); }