Class implementation form RingBuffer object
Should allow for push and pop operations on it,
reusing indexes (when free), saving up space.
Will wrap arround and use freed up places to save
up newly pushed values.
arg size - size of ringbuffer
Example
[ _ _ _ _ ] - new RingBuffer(4)
[ 1 _ _ _ ] - push(1)
[ 1 2 _ _ ] - push(2)
[ _ 2 _ _ ] - pop()
[ _ 2 3 _ ] - push(3)
[ _ _ 3 _ ] - pop()
[ _ _ 3 4 ] - push(4)
[ 5 _ 3 4 ] - push(5)
[ 5 6 3 4 ] - push(6)
[ 5 6 3 4 ] - push(7) // Buffer is full, 7 is not added
Class implementation form RingBuffer object Should allow for push and pop operations on it, reusing indexes (when free), saving up space. Will wrap arround and use freed up places to save up newly pushed values.
arg size - size of ringbuffer
Example
[ _ _ _ _ ]
- new RingBuffer[ 1 _ _ _ ]
- push(1)[ 1 2 _ _ ]
- push(2)[ _ 2 _ _ ]
- pop()[ _ 2 3 _ ]
- push(3)[ _ _ 3 _ ]
- pop()[ _ _ 3 4 ]
- push(4)[ 5 _ 3 4 ]
- push(5)[ 5 6 3 4 ]
- push(6)[ 5 6 3 4 ]
- push(7) // Buffer is full, 7 is not added[ 5 6 _ 4 ]
- pop()[ 5 6 _ _ ]
- pop()[ _ 6 _ _ ]
- pop()[ _ 6 7 _ ]
- push(7)