public class NumberRingBuffer extends Object
Modifier and Type | Field and Description |
---|---|
protected int[] |
buf |
protected int |
chunkSize
Größe der Blöcke
|
protected int |
firstElem
Zeiger auf Beginn und Ende des Ringpuffers
|
protected boolean |
isEmpty |
protected int |
lastElem
Zeiger auf Beginn und Ende des Ringpuffers
|
protected int |
maxSize
Maximale Größe der Warteschlange
|
static int |
MIN_CHUNK_SIZE
Minimale Blockgroesse
|
protected int |
noOfChunks
Anzahl der Blöcke
|
static int |
UNBOUNDED_SIZE
Minimale Blockgroesse
|
Constructor and Description |
---|
NumberRingBuffer(int chnkSize,
int mxSize) |
Modifier and Type | Method and Description |
---|---|
protected void |
adjustSizePostDecr() |
protected void |
adjustSizePreIncr() |
void |
changeMaxSize(int delta)
Aendert die Maximale Groesse um den angegebenen Wert
|
protected void |
copy2NewArray(int newSize) |
boolean |
isEmpty() |
protected boolean |
isFirstElemOneAheadOfLastElem() |
boolean |
isFull()
Zeigt ob der Buffer vollständig gefüllt ist.
|
int |
maxSize() |
protected int |
oneStepFurther(int ptr) |
int |
pop()
Liefert das erste Element der Warteschlange.
|
boolean |
push(int elem)
Fügt ein Objekt in die Warteschlange an letzter Stelle ein.
|
int |
size() |
String |
status() |
public static final int MIN_CHUNK_SIZE
public static final int UNBOUNDED_SIZE
protected int firstElem
protected int lastElem
protected int noOfChunks
protected int chunkSize
protected int maxSize
protected int[] buf
protected boolean isEmpty
public NumberRingBuffer(int chnkSize, int mxSize)
chnkSize
- Größe der Blöcke, um die das Feld der Warteschlange wächst und schrumpft. Die empfohlene Mindestgröße für diesen Parameter ist
16
.mxSize
- Maximale Groesse der Warteschlange. Wird diese ueberschritten, liefert #push(Object)
false. Wenn dieser Parameter UNBOUNDED_SIZE
ist, ist die Groesse unbegrenzt.public int maxSize()
UNBOUNDED_SIZE
.public void changeMaxSize(int delta)
delta
- positiv oder negativpublic boolean push(int elem)
elem
- Einzufügendes Objektpublic int pop() throws InterruptedException
InterruptedException
public String status()
public int size()
public boolean isEmpty()
protected void adjustSizePreIncr()
protected void adjustSizePostDecr()
protected void copy2NewArray(int newSize)
protected int oneStepFurther(int ptr)
protected boolean isFirstElemOneAheadOfLastElem()
public boolean isFull()
true
falls der Buffer vollständig gefüllt.false
sonst.