All Packages Class Hierarchy This Package Previous Next Index
Class jcsp.util.ints.BufferInt
java.lang.Object
|
+----jcsp.lang.ints.ChannelDataStoreInt
|
+----jcsp.util.ints.BufferInt
- public class BufferInt
- extends ChannelDataStoreInt
Description
The BufferInt class is an implementation of ChannelDataStoreInt which allows
more than one int to be sent across the ChannelInt at any one time. The
BufferInt will store the ints and allow them to be read in the same order
as they were written. A BufferInt of size 0 acts the same as the ZeroBufferInt
ChannelDataStoreInt.
The getState method will return EMPTY if the ChannelInt does not contain
any ints, FULL if it cannot accept more data and NONEMPTYFULL otherwise.
- Author:
- P.D.Austin
-
BufferInt(int)
- Construct a new BufferInt with the specified size.
-
clone()
- Returns a new Object with the same creation parameters as this Object.
-
get()
- Returns the first int from the BufferInt and removes the int from
the BufferInt.
-
getState()
- Returns the current state of the BufferInt, should be called to ensure
the Pre-conditions of the other methods are not broken.
-
put(int)
- Puts a new int into the BufferInt.
BufferInt
public BufferInt(int size)
- Construct a new BufferInt with the specified size.
- Parameters:
- size - The number of ints the BufferInt can store
get
protected int get()
- Returns the first int from the BufferInt and removes the int from
the BufferInt.
NOTE: getState should be called before this method to check that the
state is not EMPTY. If the state is EMPTY the BufferInt will be left in
an undefined state.
Pre-condition: The state must not be EMPTY
- Returns:
- The next available int from the BufferInt
- Overrides:
- get in class ChannelDataStoreInt
put
protected void put(int value)
- Puts a new int into the BufferInt.
NOTE: getState should be called before this method to check that the
state is not FULL. If the state is FULL the BufferInt will be left in
an undefined state.
Pre-condition: The state must not be FULL
- Parameters:
- value - The int to put in the BufferInt
- Overrides:
- put in class ChannelDataStoreInt
getState
protected int getState()
- Returns the current state of the BufferInt, should be called to ensure
the Pre-conditions of the other methods are not broken.
- Returns:
- The current state of the BufferInt (EMPTY, NONEMPTYFULL or FULL)
- Overrides:
- getState in class ChannelDataStoreInt
clone
protected Object clone()
- Returns a new Object with the same creation parameters as this Object.
This method should be overridden by subclasses to return a new Object
that is the same type as this Object. The new instance should be created
by constructing a new instance with the same parameters as the original.
NOTE: Only the sizes of the data should be cloned not the stored data.
- Returns:
- The cloned instance of this Object.
- Overrides:
- clone in class ChannelDataStoreInt
All Packages Class Hierarchy This Package Previous Next Index