public override T this[int index] { get { if (index >= 0 && index < _size) { Node <T> result = _first; for (int i = 0; i < index; i++) { result = result.GetNext(); } return(result.GetItem()); } throw new IndexOutOfRangeException(); } set { if (index >= 0 && index < _size) { Node <T> result = _first; for (int i = 0; i < index; i++) { result = result.GetNext(); } result.SetItem(value); } else { throw new IndexOutOfRangeException(); } } }
public override void Add(T item) { if (_count < _size) { _end = _end.GetNext(); _end.SetItem(item); _count++; OnAddElement(new DataStructEventArgs <T>(item)); } else { OnContainerFull(new DataStructEventArgs <T>(item)); throw new DataStructureIsFullOnInsertExeption("RingBufferLinkedList"); } }
public override void Add(T item) { Node <T> node = new Node <T>(item); node.SetItem(item); if (_size == 0) { _first = node; _last = node; } else { _first.SetPrevious(node); node.SetNext(_first); _first = node; } OnAddElement(new DataStructEventArgs <T>(node.GetItem())); _size++; }