Example 1
Input
RingBuffer 2
push a
push b
push c
snapshotOutput
null
null
null
b cImplement RingBuffer, a fixed-capacity ring buffer for events. The buffer stores events in insertion order and automatically drops the oldest event when full.
RingBuffer(capacity)capacity.capacity is guaranteed to be a positive integer.push(event)string type.null.snapshot()snapshot() must not modify the internal state of the buffer.RingBuffer 2
push a
push b
push c
snapshotnull
null
null
b cRingBuffer 3
push 1
push 2
snapshotnull
null
1 2