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