E - the element to be placed in this buffer.public class DefaultCyclicBuffer<E extends Sequenced> extends Object implements CyclicBuffer<E>
CyclicBuffer interface.
 This class is not thread-safe and only one thread can access it at a time.CyclicBuffer| Constructor and Description | 
|---|
DefaultCyclicBuffer(int capacity)  | 
| 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. 
 | 
public DefaultCyclicBuffer(int capacity)
                    throws IllegalArgumentException
IllegalArgumentExceptionpublic void add(E event)
CyclicBufferadd in interface CyclicBuffer<E extends Sequenced>event - the event to be added.public E get(long sequence)
CyclicBuffersequence.get in interface CyclicBuffer<E extends Sequenced>sequence - the sequence number of the event.sequence.public boolean setHead(long sequence)
CyclicBuffersequence and returns true, if that sequence
 is still in this buffer. Otherwise, returns falsesetHead in interface CyclicBuffer<E extends Sequenced>sequence - the sequence number which will be set to head of this buffer.true if sequence is set to head, otherwise returns false.public E getAndAdvance()
CyclicBuffergetAndAdvance in interface CyclicBuffer<E extends Sequenced>public void reset()
CyclicBufferreset in interface CyclicBuffer<E extends Sequenced>public int size()
CyclicBuffersize in interface CyclicBuffer<E extends Sequenced>public long getHeadSequence()
CyclicBuffer-1L will be returned.getHeadSequence in interface CyclicBuffer<E extends Sequenced>-1L.Copyright © 2019 Hazelcast, Inc.. All Rights Reserved.