All Packages Class Hierarchy This Package Previous Next Index
Class jcsp.util.ints.OverWritingBufferInt
java.lang.Object
|
+----jcsp.lang.ints.ChannelDataStoreInt
|
+----jcsp.util.ints.OverWritingBufferInt
- public class OverWritingBufferInt
- extends ChannelDataStoreInt
Description
The OverWritingBufferInt class is an implementation of ChannelDataStoreInt which allows
more than one int to be sent across the ChannelInt at any one time. The
OverWritingBufferInt will store the ints and allow them to be read in the same order
as they were written. When the OverWritingBufferInt is FULL the last int
written will be discarded and the new value put in it's place.
The getState method will return EMPTY if the Channel does not contain
any ints and NONEMPTYFULL otherwise.
- Author:
- P.D.Austin
-
OverWritingBufferInt(int)
- Construct a new OverWritingBufferInt with the specified size.
-
clone()
- Returns a new Object with the same creation parameters as this Object.
-
get()
- Returns the first int from the OverWritingBufferInt and removes the int from
the BufferInt.
-
getState()
- Returns the current state of the OverWritingBufferInt, should be called to ensure
the Pre-conditions of the other methods are not broken.
-
put(int)
- Puts a new int into the OverWritingBufferInt.
OverWritingBufferInt
public OverWritingBufferInt(int size)
- Construct a new OverWritingBufferInt with the specified size.
- Parameters:
- size - The number of ints the BufferInt can store
get
protected int get()
- Returns the first int from the OverWritingBufferInt 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 OverWritingBufferInt will be left in
an undefined state.
Pre-condition: The state must not be EMPTY
- Returns:
- The next available int from the OverWritingBufferInt
- Overrides:
- get in class ChannelDataStoreInt
put
protected void put(int value)
- Puts a new int into the OverWritingBufferInt. If the OverWritingBufferInt
is FULL the last element added will be over writen.
- Parameters:
- value - The int to put in the OverWritingBufferInt
- Overrides:
- put in class ChannelDataStoreInt
getState
protected int getState()
- Returns the current state of the OverWritingBufferInt, should be called to ensure
the Pre-conditions of the other methods are not broken.
- Returns:
- The current state of the OverWritingBufferInt (EMPTY or NONEMPTYFULL)
- 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