|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rit.mp.Buf
edu.rit.mp.BooleanBuf
public abstract class BooleanBuf
Class BooleanBuf is the abstract base class for a buffer of Boolean items sent or received using the Message Protocol (MP). In a message, a Boolean item is represented as one byte, 0 for false, 1 for true.
A buffer may be used to send one or more messages at the same time in multiple threads. If a buffer is being used to send a message or messages, the buffer must not be used to receive a message at the same time.
A buffer may be used to receive one message at a time. If a buffer is being used to receive a message, the buffer must not be used to receive another message in a different thread, and the buffer must not be used to send a message or messages.
A buffer is a conduit for retrieving and storing data in some underlying data structure. If the underlying data structure is multiple thread safe, then one thread can be retrieving or storing data via the buffer at the same time as other threads are accessing the data structure. If the underlying data structure is not multiple thread safe, then other threads must not access the data structure while one thread is retrieving or storing data via the buffer.
To create a BooleanBuf, call one of the following static factory methods:
| Field Summary |
|---|
| Fields inherited from class edu.rit.mp.Buf |
|---|
myLength |
| Constructor Summary | |
|---|---|
protected |
BooleanBuf(int theLength)
Construct a new Boolean buffer. |
| Method Summary | |
|---|---|
static BooleanItemBuf |
buffer()
Create a buffer for a Boolean item. |
static BooleanItemBuf |
buffer(boolean item)
Create a buffer for a Boolean item with the given initial value. |
static BooleanBuf |
buffer(boolean[] theArray)
Create a buffer for the entire given Boolean array. |
static BooleanBuf |
buffer(boolean[][] theMatrix)
Create a buffer for the entire given Boolean matrix. |
static BooleanBuf |
buffer(SharedBoolean item)
Create a buffer for a shared Boolean item. |
static BooleanBuf |
buffer(SharedBooleanArray theArray)
Create a buffer for the entire given shared Boolean array. |
static BooleanBuf |
colSliceBuffer(boolean[][] theMatrix,
Range theColRange)
Create a buffer for one column slice of the given Boolean matrix. |
static BooleanBuf[] |
colSliceBuffers(boolean[][] theMatrix,
Range[] theColRanges)
Create an array of buffers for multiple column slices of the given Boolean matrix. |
void |
copy(Buf theSrc)
Copy items from the given buffer to this buffer. |
protected static void |
defaultCopy(BooleanBuf theSrc,
BooleanBuf theDst)
Copy items from the given source buffer to the given destination buffer. |
static BooleanBuf |
emptyBuffer()
Create an empty buffer. |
void |
fill(Object item)
Fill this buffer with the given item. |
abstract boolean |
get(int i)
Obtain the given item from this buffer. |
Buf |
getTemporaryBuf()
Create a temporary buffer with the same type of items and the same length as this buffer. |
static BooleanBuf |
patchBuffer(boolean[][] theMatrix,
Range theRowRange,
Range theColRange)
Create a buffer for one patch of the given Boolean matrix. |
static BooleanBuf[] |
patchBuffers(boolean[][] theMatrix,
Range[] theRowRanges,
Range[] theColRanges)
Create an array of buffers for multiple patches of the given Boolean matrix. |
abstract void |
put(int i,
boolean item)
Store the given item in this buffer. |
static BooleanBuf |
rowSliceBuffer(boolean[][] theMatrix,
Range theRowRange)
Create a buffer for one row slice of the given Boolean matrix. |
static BooleanBuf[] |
rowSliceBuffers(boolean[][] theMatrix,
Range[] theRowRanges)
Create an array of buffers for multiple row slices of the given Boolean matrix. |
static BooleanBuf |
sliceBuffer(boolean[] theArray,
Range theRange)
Create a buffer for one slice of the given Boolean array. |
static BooleanBuf |
sliceBuffer(SharedBooleanArray theArray,
Range theRange)
Create a buffer for one slice of the given shared Boolean array. |
static BooleanBuf[] |
sliceBuffers(boolean[] theArray,
Range[] theRanges)
Create an array of buffers for multiple slices of the given Boolean array. |
static BooleanBuf[] |
sliceBuffers(SharedBooleanArray theArray,
Range[] theRanges)
Create an array of buffers for multiple slices of the given shared Boolean array. |
| Methods inherited from class edu.rit.mp.Buf |
|---|
getReductionBuf, length, receiveItems, sendItems |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected BooleanBuf(int theLength)
theLength - Number of items.
IllegalArgumentException - (unchecked exception) Thrown if theLength < 0.| Method Detail |
|---|
public static BooleanBuf emptyBuffer()
public static BooleanItemBuf buffer()
public static BooleanItemBuf buffer(boolean item)
item - Initial value of the item field.
public static BooleanBuf buffer(boolean[] theArray)
theArray - Array.
NullPointerException - (unchecked exception) Thrown if theArray is null.
public static BooleanBuf sliceBuffer(boolean[] theArray,
Range theRange)
theArray - Array.theRange - Range of elements to include.
NullPointerException - (unchecked exception) Thrown if theArray is null or
theRange is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if theArray does not include
all the indexes in theRange.
public static BooleanBuf[] sliceBuffers(boolean[] theArray,
Range[] theRanges)
theArray - Array.theRanges - Array of ranges of elements to include.
NullPointerException - (unchecked exception) Thrown if theArray is null or
theRanges or any element thereof is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if theArray's allocation does
not include any element of theRanges.public static BooleanBuf buffer(boolean[][] theMatrix)
theMatrix - Matrix.
NullPointerException - (unchecked exception) Thrown if theMatrix is null.
public static BooleanBuf rowSliceBuffer(boolean[][] theMatrix,
Range theRowRange)
theMatrix - Matrix.theRowRange - Range of rows to include.
NullPointerException - (unchecked exception) Thrown if theMatrix is null or
theRowRange is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if theMatrix's allocation does
not include theRowRange.
public static BooleanBuf[] rowSliceBuffers(boolean[][] theMatrix,
Range[] theRowRanges)
theMatrix - Matrix.theRowRanges - Array of ranges of rows to include.
NullPointerException - (unchecked exception) Thrown if theMatrix is null or
theRowRanges or any element thereof is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if theMatrix's allocation does
not include any element of theRowRanges.
public static BooleanBuf colSliceBuffer(boolean[][] theMatrix,
Range theColRange)
theMatrix - Matrix.theColRange - Range of columns to include.
NullPointerException - (unchecked exception) Thrown if theMatrix is null or
theColRange is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if theMatrix's allocation does
not include theColRange.
public static BooleanBuf[] colSliceBuffers(boolean[][] theMatrix,
Range[] theColRanges)
theMatrix - Matrix.theColRanges - Array of ranges of columns to include.
NullPointerException - (unchecked exception) Thrown if theMatrix is null or
theColRanges or any element thereof is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if theMatrix's allocation does
not include any element of theColRanges.
public static BooleanBuf patchBuffer(boolean[][] theMatrix,
Range theRowRange,
Range theColRange)
theMatrix - Matrix.theRowRange - Range of rows to include.theColRange - Range of columns to include.
NullPointerException - (unchecked exception) Thrown if theMatrix is null,
theRowRange is null, or theColRange is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if theMatrix's allocation does
not include theRowRange and theColRange.
public static BooleanBuf[] patchBuffers(boolean[][] theMatrix,
Range[] theRowRanges,
Range[] theColRanges)
theMatrix - Matrix.theRowRanges - Array of ranges of rows to include.theColRanges - Array of ranges of columns to include.
NullPointerException - (unchecked exception) Thrown if theMatrix is null,
theRowRanges or any element thereof is null, or
theColRanges or any element thereof is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if theMatrix's allocation does
not include any element of theRowRanges or
theColRanges.public static BooleanBuf buffer(SharedBoolean item)
item - SharedBoolean object that wraps the item.
NullPointerException - (unchecked exception) Thrown if item is null.public static BooleanBuf buffer(SharedBooleanArray theArray)
theArray - Array.
NullPointerException - (unchecked exception) Thrown if theArray is null.
public static BooleanBuf sliceBuffer(SharedBooleanArray theArray,
Range theRange)
theArray - Array.theRange - Range of elements to include.
NullPointerException - (unchecked exception) Thrown if theArray is null or
theRange is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if theArray does not include
all the indexes in theRange.
public static BooleanBuf[] sliceBuffers(SharedBooleanArray theArray,
Range[] theRanges)
theArray - Array.theRanges - Array of ranges of elements to include.
NullPointerException - (unchecked exception) Thrown if theArray is null or
theRanges or any element thereof is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if theArray's allocation does
not include any element of theRanges.public abstract boolean get(int i)
The get() method must not block the calling thread; if it does, all message I/O in MP will be blocked.
i - Item index in the range 0 .. length()-1.
public abstract void put(int i,
boolean item)
The put() method must not block the calling thread; if it does, all message I/O in MP will be blocked.
i - Item index in the range 0 .. length()-1.item - Item to be stored at index i.public void copy(Buf theSrc)
The default implementation of the copy() method calls the defaultCopy() method. A subclass can override the copy() method to use a more efficient algorithm.
copy in class BuftheSrc - Source of items to copy into this buffer.
ClassCastException - (unchecked exception) Thrown if theSrc's item data type is
not the same as this buffer's item data type.public void fill(Object item)
The item must be an instance of class Boolean. If the item is null, false is assigned to each element in this buffer.
fill in class Bufitem - Item.
ClassCastException - (unchecked exception) Thrown if the item's data type is not
the same as this buffer's item data type.public Buf getTemporaryBuf()
getTemporaryBuf in class Buf
protected static void defaultCopy(BooleanBuf theSrc,
BooleanBuf theDst)
theSrc - Source of items to copy.theDst - Destination of items to copy.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||