public class InfiniteBufferInt
This is used to create a buffered integer 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 |
---|
InfiniteBufferInt
() Construct a new InfiniteBufferInt with the default size (of 8). |
InfiniteBufferInt
(int initialSize) Construct a new InfiniteBufferInt with the specified initial size. |
Type | Name and description |
---|---|
Object |
clone() Returns a new (and EMPTY) InfiniteBufferInt with the same creation parameters as this one. |
void |
endGet() Removes the oldest integer from the buffer. |
int |
get() Returns the oldest int from the InfiniteBufferInt and removes it. |
int |
getState() Returns the current state of the InfiniteBufferInt. |
void |
put(int value) Puts a new int into the InfiniteBufferInt. |
void |
removeAll() |
int |
startGet() Returns the oldest integer from the buffer but does not remove it. |
Construct a new InfiniteBufferInt with the default size (of 8).
Construct a new InfiniteBufferInt with the specified initial size.
initialSize
- the number of ints
the InfiniteBufferInt can initially store.Returns a new (and EMPTY) InfiniteBufferInt with the same creation parameters as this one.
Note: Only the initial size and structure of the InfiniteBufferInt is cloned, not any stored data.
Removes the oldest integer from the buffer.
Returns the oldest int from the InfiniteBufferInt and removes it.
Pre-condition: getState must not currently return EMPTY.
Returns the current state of the InfiniteBufferInt.
Puts a new int into the InfiniteBufferInt.
Implementation note: if InfiniteBufferInt is full, a new internal buffer with double the capacity is constructed and the old data copied across.
value
- the int to put into the InfiniteBufferIntReturns the oldest integer 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