Buffer implements Iterable<T> { public void add(final T value) { _buffer[_index] = value; if (++_index == _buffer.length) { _index = 0; } if (_size < _buffer.length) { ++_size; } } private  Buffer(final int capacity); int capacity(); int size(); boolean isEmpty(); void add(final T value); @SafeVarargs final void addAll(final T... values); void addAll(final Iterable<? extends T> values); @Override Iterator<T> iterator(); Object[] toArray(); A[] toArray(final IntFunction<A[]> generator); ISeq<T> toSeq(); @Override String toString(); static Buffer<T> ofCapacity(final int capacity);  }
@Test public void add() { final Buffer<Integer> buffer = Buffer.ofCapacity(10); buffer.add(1); buffer.add(2); buffer.add(3); Assert.assertEquals(buffer.toSeq(), ISeq.of(1, 2, 3)); Assert.assertEquals( ISeq.of(buffer.toArray(Integer[]::new)), ISeq.of(1, 2, 3) ); }