public abstract class AbstractRingBuffer extends AbstractPipe
Pipe by a "backing store" of bytes with fixed size (the "capacity").
Implementation must implement methods get(long, byte[], int, int) and put(byte[], int, int, long)
to provide access to the backing store.
| Constructor and Description |
|---|
AbstractRingBuffer(long capacity) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
get(long pos,
byte[] buf,
int off,
int len)
Transfers len bytes from the backing store to buf
[off].... |
boolean |
isEmpty() |
boolean |
isFull() |
protected abstract void |
put(byte[] buf,
int off,
int len,
long pos)
Transfers len bytes from
buf[off]... to the backing store. |
int |
read(byte[] buf,
int off,
int len)
Reads at most len bytes from this pipe into the buf at offset off.
|
int |
write(byte[] buf,
int off,
int len)
Writes at most len bytes from buf at offset off to this pipe.
|
finalize, read, writepublic AbstractRingBuffer(long capacity)
capacity - The size of the backing storeprotected abstract void get(long pos,
byte[] buf,
int off,
int len)
throws IOException
[off]....pos - 0...capacityoff - 0...buf.lengthlen - 0...min(capacity - pos, buf.length - offIOExceptionAbstractRingBuffer(long)protected abstract void put(byte[] buf,
int off,
int len,
long pos)
throws IOException
buf[off]... to the backing store.off - 0...buf.lengthlen - 0...min(capacity - pos, buf.length - offpos - 0...capacityIOExceptionAbstractRingBuffer(long)public final int read(byte[] buf,
int off,
int len)
throws IOException
Pipe1 ... len); 0 iff this pipe is emptyIOExceptionpublic final int write(byte[] buf,
int off,
int len)
throws IOException
Pipe1 ... len); 0 iff this pipe is fullIOExceptionpublic final boolean isEmpty()
Pipe.read(byte[], int, int) will return 0public final boolean isFull()
Pipe.write(byte[], int, int) will return 0Copyright © 2018 Arno Unkrig. All rights reserved.