All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jcsp.util.ints.InfiniteBufferInt

java.lang.Object
   |
   +----jcsp.lang.ints.ChannelDataStoreInt
           |
           +----jcsp.util.ints.InfiniteBufferInt

public class InfiniteBufferInt
extends ChannelDataStoreInt

Description

The InfiniteBufferInt class is an implementation of ChannelDataStoreInt which allows more than one int to be sent across the ChannelInt at any one time. The InfiniteBufferInt will store the ints and allow them to be read in the same order as they were written. An initial size for the buffer can be specified upon creation, if the buffer becomes full it will be expanded to accept more data.

The getState method will return EMPTY if the Channel does not contain any ints and NONEMPTYFULL otherwise.

Author:
P.D.Austin

Constructor Index

 o InfiniteBufferInt()
Construct a new InfiniteBufferInt with the default size.
 o InfiniteBufferInt(int)
Construct a new InfiniteBufferInt with the specified size.

Method Index

 o clone()
Returns a new Object with the same creation parameters as this Object.
 o get()
Returns the first int from the InfiniteBufferInt and removes the int from the InfiniteBufferInt.
 o getState()
Returns the current state of the InfiniteBufferInt, should be called to ensure the Pre-conditions of the other methods are not broken.
 o put(int)
Puts a new int into the InfiniteBufferInt.

Constructors

 o InfiniteBufferInt
 public InfiniteBufferInt()
Construct a new InfiniteBufferInt with the default size.

 o InfiniteBufferInt
 public InfiniteBufferInt(int initialSize)
Construct a new InfiniteBufferInt with the specified size.

Parameters:
size - The initial number of ints the InfiniteBufferInt can store

Methods

 o get
 protected int get()
Returns the first int from the InfiniteBufferInt and removes the int from the InfiniteBufferInt.

NOTE: getState should be called before this method to check that the state is not EMPTY. If the state is EMPTY the InfiniteBufferInt will be left in an undefined state.

Pre-condition: The state must not be EMPTY

Returns:
The next available int from the InfiniteBufferInt
Overrides:
get in class ChannelDataStoreInt
 o put
 protected void put(int value)
Puts a new int into the InfiniteBufferInt.

Parameters:
value - The int to put in the InfiniteBufferInt
Overrides:
put in class ChannelDataStoreInt
 o getState
 protected int getState()
Returns the current state of the InfiniteBufferInt, should be called to ensure the Pre-conditions of the other methods are not broken.

Returns:
The current state of the InfiniteBufferInt (EMPTY, NONEMPTYFULL or FULL)
Overrides:
getState in class ChannelDataStoreInt
 o 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