public class Buffer
This is used to create a buffered object channel that never loses data.
The getState method returns EMPTY, NONEMPTYFULL or FULL according to the state of the buffer.
Constructor and description |
---|
Buffer
(int size) Construct a new Buffer with the specified size. |
Type | Name and description |
---|---|
Object |
clone() Returns a new (and EMPTY) Buffer 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 Buffer and removes it. |
int |
getState() Returns the current state of the Buffer. |
void |
put(Object value) Puts a new Object into the Buffer. |
void |
removeAll() |
Object |
startGet() Returns the oldest object from the buffer but does not remove it. |
Construct a new Buffer with the specified size.
size
- the number of Objects the Buffer can store.Returns a new (and EMPTY) Buffer with the same creation parameters as this one.
Note: Only the size and structure of the Buffer is cloned, not any stored data.
Removes the oldest object from the buffer.
Returns the oldest Object from the Buffer and removes it.
Pre-condition: getState must not currently return EMPTY.
Returns the current state of the Buffer.
Puts a new Object into the Buffer.
Pre-condition: getState must not currently return FULL.
value
- the Object to put into the BufferReturns 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