public override T Get() { if (_size == 0) { throw new DataStructureIsEmptyOnReadExeption("Linked List"); } Node <T> result = _last; _last = _last.GetPrevious(); if (_size == 1) { Clear(); } else { _last.SetNext(null); _size--; } OnRemoveElement(new DataStructEventArgs <T>(result.GetItem())); return(result.GetItem()); }
public RingBufferLinkedList(int length) { if (length < 1) { throw new ArgumentException(); } _first = new Node <T>(); Node <T> currentNode = _first; for (int i = 0; i < length - 1; i++) { currentNode.SetNext(new Node <T>()); currentNode.GetNext().SetPrevious(currentNode); currentNode = currentNode.GetNext(); } currentNode.SetNext(_first); _first.SetPrevious(currentNode); _size = length; _end = _first.GetPrevious(); }
public override void Clear() { _end = _first.GetPrevious(); _count = 0; OnContainerEmpty(new DataStructEventArgs <T>()); }