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, write
public 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.length
len
- 0...min(capacity - pos, buf.length - off
IOException
AbstractRingBuffer(long)
protected abstract void put(byte[] buf, int off, int len, long pos) throws IOException
buf[off]...
to the backing store.off
- 0...buf.length
len
- 0...min(capacity - pos, buf.length - off
pos
- 0...capacityIOException
AbstractRingBuffer(long)
public final int read(byte[] buf, int off, int len) throws IOException
Pipe
1 ... len
); 0 iff this pipe is emptyIOException
public final int write(byte[] buf, int off, int len) throws IOException
Pipe
1 ... len
); 0 iff this pipe is fullIOException
public 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.