public class InfiniteBuffer
This is used to create a buffered object channel that always accepts and never loses any input.
The getState method returns EMPTY or NONEMPTYFULL, but never FULL.
An initial size for the buffer can be specified during construction.
Constructor and description |
---|
InfiniteBuffer
() Construct a new InfiniteBuffer with the default size (of 8). |
InfiniteBuffer
(int initialSize) Construct a new InfiniteBuffer with the specified initial size. |
Type | Name and description |
---|---|
Object |
clone() Returns a new (and EMPTY) InfiniteBuffer with the same creation parameters as this one. |
void |
endGet() Removes the oldest object from the buffer. |
Object |
get() Returns the oldest Object from the InfiniteBuffer and removes it. |
int |
getState() Returns the current state of the InfiniteBuffer. |
void |
put(Object value) Puts a new Object into the InfiniteBuffer. |
void |
removeAll() |
Object |
startGet() Returns the oldest object from the buffer but does not remove it. |
Construct a new InfiniteBuffer with the default size (of 8).
Construct a new InfiniteBuffer with the specified initial size.
initialSize
- the number of Objects
the InfiniteBuffer can initially store.Returns a new (and EMPTY) InfiniteBuffer with the same creation parameters as this one.
Note: Only the initial size and structure of the InfiniteBuffer is cloned, not any stored data.
Removes the oldest object from the buffer.
Returns the oldest Object from the InfiniteBuffer and removes it.
Pre-condition: getState must not currently return EMPTY.
Returns the current state of the InfiniteBuffer.
Puts a new Object into the InfiniteBuffer.
Implementation note: if InfiniteBuffer is full, a new internal buffer with double the capacity is constructed and the old data copied across.
value
- the Object to put into the InfiniteBufferReturns the oldest object from the buffer but does not remove it. Pre-condition: getState must not currently return EMPTY.
JCSP for Java 1.8 generated 14-10-2016 by Jon Kerridge, Edinburgh Napier University - j dot kerridge at napier dot ac dot uk