add method

  1. @override
void add(
  1. T element
)
override

Add element to the buffer. If the buffer was already at capacity, remove the least recently added element.

Implementation

@override
void add(T element) {
  if (_last == -1) {
    _store[_last = 0] = element;
  } else {
    _last = (_last + 1) % _store.length;
    _store[_last] = element;
    if (_last == _first) {
      _first = (_first + 1) % _store.length;
      assert(length == _store.length);
    }
  }
}