Constructor and Description |
---|
RingbufferMergeData(int capacity) |
RingbufferMergeData(Ringbuffer<Object> ringbuffer) |
Modifier and Type | Method and Description |
---|---|
long |
add(Object item)
Adds an item to the tail of the ringbuffer.
|
void |
clear()
Clears the data in the ringbuffer.
|
int |
getCapacity()
Returns the capacity of this ringbuffer.
|
long |
getHeadSequence()
Returns the sequence of the head.
|
Object[] |
getItems()
Returns the array representing this ringbuffer.
|
long |
getTailSequence()
Returns the sequence of the tail.
|
Iterator<Object> |
iterator()
Returns a read-only iterator.
|
<E> E |
read(long sequence)
Reads one item from the ringbuffer.
|
void |
set(long seq,
Object data)
Sets the item at the given sequence.
|
void |
setHeadSequence(long sequence)
Sets the head sequence.
|
void |
setTailSequence(long sequence)
Sets the tail sequence.
|
int |
size()
Returns number of items in the ringbuffer (meaning the number of items
between the
getHeadSequence() and getTailSequence() ). |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public RingbufferMergeData(int capacity)
public RingbufferMergeData(Ringbuffer<Object> ringbuffer)
public long getTailSequence()
The initial value of the tail is -1
.
public void setTailSequence(long sequence)
headSequence() - 1
.sequence
- the new tail sequenceIllegalArgumentException
- if the target sequence is less than
headSequence() - 1
getHeadSequence()
public long getHeadSequence()
If the RingBuffer is empty, the head will be one more than the
getTailSequence()
.
The initial value of the head is 0 (1 more than tail).
public void setHeadSequence(long sequence)
tailSequence() + 1
.sequence
- the new head sequenceIllegalArgumentException
- if the target sequence is greater than tailSequence() + 1
getTailSequence()
public int getCapacity()
public int size()
getHeadSequence()
and getTailSequence()
).public long add(Object item)
The returned value is the sequence of the added item. Using this sequence you can read the added item.
item
- the item to addpublic <E> E read(long sequence)
E
- ringbuffer item typesequence
- the sequence of the item to readStaleSequenceException
- if the sequence is smaller then getHeadSequence()
or larger than getTailSequence()
public void set(long seq, Object data)
null
data.seq
- the target sequencedata
- the data to be setpublic void clear()
public Object[] getItems()
Items at the beginning of this array may have higher sequence IDs than items at the end of this array. This means that this array is not sorted by sequence ID and the index of the item in this array must be calculated using the sequence and the modulo of the array.
Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.