E - the generic Object to be storedpublic class CircularBuffer<E> extends Object
| Constructor and Description |
|---|
CircularBuffer(E[] initalElements,
int capacity) |
CircularBuffer(int capacity) |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
int |
capacity() |
E[] |
elements(E[] returnVectorType) |
E |
get() |
E[] |
get(E[] into,
int length) |
E[] |
get(E[] into,
int readPos,
int length) |
E |
get(int readPos) |
protected int |
getIndex(int readPos) |
boolean |
isBufferFlipped() |
boolean |
put(E element) |
int |
put(E[] newElements,
int length)
add multiple new elements
|
int |
put(E[] newElements,
int startIndex,
int length)
add multiple new elements
|
int |
remainingCapacity() |
E |
replace(E element) |
E |
replace(E element,
int atIndex) |
void |
reset()
resets buffer
|
int |
writePosition() |
public CircularBuffer(E[] initalElements, int capacity)
initalElements - adds element the buffer should be initialised withcapacity - maximum capacity of the bufferpublic CircularBuffer(int capacity)
capacity - maximum capacity of the bufferpublic int available()
public int capacity()
public E[] elements(E[] returnVectorType)
returnVectorType - need to supply export type vectorpublic E get()
public E[] get(E[] into, int length)
into - storage containerlength - number of elements to be readpublic E[] get(E[] into, int readPos, int length)
into - storage containerreadPos - circular index (wraps around)length - number of elements to be readpublic E get(int readPos)
readPos - circular index (wraps around)protected int getIndex(int readPos)
public boolean isBufferFlipped()
public boolean put(E element)
element - new elementpublic int put(E[] newElements, int length)
newElements - array of new elementslength - number of elements that are to be written from arraypublic int put(E[] newElements, int startIndex, int length)
newElements - array of new elementsstartIndex - 'null'length - number of elements that are to be written from arraypublic int remainingCapacity()
public E replace(E element)
element - to replace an existing element at the head buffer positionpublic E replace(E element, int atIndex)
element - to replace an existing element at given buffer positionatIndex - index at which to replace the valuepublic void reset()
public int writePosition()
Copyright © 2020 GSI Helmholtzzentrum für Schwerionenforschung GmbH. All rights reserved.