E
- the type of elements in this buffer.public interface CyclicBuffer<E extends Sequenced>
Sequenced
events. Only additions can be done to this buffer.
If capacity is not sufficient subsequent additions will be done by overwriting existing ones.
Also read access to any element is possible by providing the sequence number.Modifier and Type | Method and Description |
---|---|
void |
add(E event)
Adds an event to this buffer and sets tail to the sequence of given event.
|
E |
get(long sequence)
Returns the element in this buffer which has the supplied
sequence . |
E |
getAndAdvance()
Returns next unread event from this buffer and advances head sequence of this buffer by one.
|
long |
getHeadSequence()
Returns the sequence number of the element in the head index of this buffer if there exists any,
otherwise
-1L will be returned. |
void |
reset()
Resets this buffer; after the return of this method buffer will be empty and
all elements in it will be null.
|
boolean |
setHead(long sequence)
Sets head of this buffer to the supplied
sequence and returns true , if that sequence
is still in this buffer. |
int |
size()
Returns the size of unread events in this buffer according to the current head.
|
void add(E event)
event
- the event to be added.E getAndAdvance()
E get(long sequence)
sequence
.sequence
- the sequence number of the event.sequence
.boolean setHead(long sequence)
sequence
and returns true
, if that sequence
is still in this buffer. Otherwise, returns false
sequence
- the sequence number which will be set to head of this buffer.true
if sequence
is set to head, otherwise returns false
.long getHeadSequence()
-1L
will be returned.-1L
.void reset()
int size()
Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.