public void AddFirst(int value) { _head = new Node1(value) { Next = _head }; }
public int DelPosition(int position) { if (position <= 0 || position > Size() || Size() == 0) { throw new IndexOutOfRangeException(); } var value = 0; var index = 0; Node1 previous = null; var current = _head; while (current != null) { if (index == position) { if (previous != null) { previous.Next = current.Next; } else { _head = _head.Next; } value = current.Value; } previous = current; current = current.Next; index++; } return(value); }
public int DelFirst() { if (Size() == 0) { throw new IndexOutOfRangeException(); } var value = _head.Value; _head = _head.Next; return value; }
public int DelFirst() { if (Size() == 0) { throw new IndexOutOfRangeException(); } var value = _head.Value; _head = _head.Next; return(value); }
public void AddLast(int value) { var node = new Node1(value); if (_head == null) { _head = node; } else { var current = _head; while (current != null) { current = current.Next; } current.Next = node; } }
public void Clear() { _head = null; }
public int DelPosition(int position) { if (position <= 0 || position > Size() || Size() == 0) { throw new IndexOutOfRangeException(); } var value = 0; var index = 0; Node1 previous = null; var current = _head; while (current != null) { if (index == position) { if (previous != null) { previous.Next = current.Next; } else { _head = _head.Next; } value = current.Value; } previous = current; current = current.Next; index++; } return value; }