|
||||||||||
| 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.Unsigned16BitIntegerBuf
public abstract class Unsigned16BitIntegerBuf
Class Unsigned16BitIntegerBuf is the abstract base class for a buffer of unsigned 16-bit integer items sent or received using the Message Protocol (MP). In a message, an unsigned 16-bit integer item is represented as two bytes, most significant byte first. The range of values that can be represented is 0 .. 65535.
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 an Unsigned16BitIntegerBuf, call one of the following static factory methods:
| Field Summary |
|---|
| Fields inherited from class edu.rit.mp.Buf |
|---|
myLength |
| Constructor Summary | |
|---|---|
protected |
Unsigned16BitIntegerBuf(int theLength)
Construct a new unsigned 16-bit integer buffer. |
| Method Summary | |
|---|---|
static Unsigned16BitIntegerItemBuf |
buffer()
Create a buffer for an integer item. |
static Unsigned16BitIntegerItemBuf |
buffer(int item)
Create a buffer for an integer item with the given initial value. |
static Unsigned16BitIntegerBuf |
buffer(int[] theArray)
Create a buffer for the entire given integer array. |
static Unsigned16BitIntegerBuf |
buffer(int[][] theMatrix)
Create a buffer for the entire given integer matrix. |
static Unsigned16BitIntegerBuf |
buffer(SharedInteger item)
Create a buffer for a shared integer item. |
static Unsigned16BitIntegerBuf |
buffer(SharedIntegerArray theArray)
Create a buffer for the entire given shared integer array. |
static Unsigned16BitIntegerBuf |
colSliceBuffer(int[][] theMatrix,
Range theColRange)
Create a buffer for one column slice of the given integer matrix. |
static Unsigned16BitIntegerBuf[] |
colSliceBuffers(int[][] theMatrix,
Range[] theColRanges)
Create an array of buffers for multiple column slices of the given integer matrix. |
void |
copy(Buf theSrc)
Copy items from the given buffer to this buffer. |
protected static void |
defaultCopy(Unsigned16BitIntegerBuf theSrc,
Unsigned16BitIntegerBuf theDst)
Copy items from the given source buffer to the given destination buffer. |
static Unsigned16BitIntegerBuf |
emptyBuffer()
Create an empty buffer. |
void |
fill(Object item)
Fill this buffer with the given item. |
abstract int |
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 Unsigned16BitIntegerBuf |
patchBuffer(int[][] theMatrix,
Range theRowRange,
Range theColRange)
Create a buffer for one patch of the given integer matrix. |
static Unsigned16BitIntegerBuf[] |
patchBuffers(int[][] theMatrix,
Range[] theRowRanges,
Range[] theColRanges)
Create an array of buffers for multiple patches of the given integer matrix. |
abstract void |
put(int i,
int item)
Store the given item in this buffer. |
static Unsigned16BitIntegerBuf |
rowSliceBuffer(int[][] theMatrix,
Range theRowRange)
Create a buffer for one row slice of the given integer matrix. |
static Unsigned16BitIntegerBuf[] |
rowSliceBuffers(int[][] theMatrix,
Range[] theRowRanges)
Create an array of buffers for multiple row slices of the given integer matrix. |
static Unsigned16BitIntegerBuf |
sliceBuffer(int[] theArray,
Range theRange)
Create a buffer for one slice of the given integer array. |
static Unsigned16BitIntegerBuf |
sliceBuffer(SharedIntegerArray theArray,
Range theRange)
Create a buffer for one slice of the given shared integer array. |
static Unsigned16BitIntegerBuf[] |
sliceBuffers(int[] theArray,
Range[] theRanges)
Create an array of buffers for multiple slices of the given integer array. |
static Unsigned16BitIntegerBuf[] |
sliceBuffers(SharedIntegerArray theArray,
Range[] theRanges)
Create an array of buffers for multiple slices of the given shared integer 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 Unsigned16BitIntegerBuf(int theLength)
theLength - Number of items.
IllegalArgumentException - (unchecked exception) Thrown if theLength < 0.| Method Detail |
|---|
public static Unsigned16BitIntegerBuf emptyBuffer()
public static Unsigned16BitIntegerItemBuf buffer()
public static Unsigned16BitIntegerItemBuf buffer(int item)
item - Initial value of the item field.
public static Unsigned16BitIntegerBuf buffer(int[] theArray)
theArray - Array.
NullPointerException - (unchecked exception) Thrown if theArray is null.
public static Unsigned16BitIntegerBuf sliceBuffer(int[] 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 Unsigned16BitIntegerBuf[] sliceBuffers(int[] 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 Unsigned16BitIntegerBuf buffer(int[][] theMatrix)
theMatrix - Matrix.
NullPointerException - (unchecked exception) Thrown if theMatrix is null.
public static Unsigned16BitIntegerBuf rowSliceBuffer(int[][] 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 Unsigned16BitIntegerBuf[] rowSliceBuffers(int[][] 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 Unsigned16BitIntegerBuf colSliceBuffer(int[][] 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 Unsigned16BitIntegerBuf[] colSliceBuffers(int[][] 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 Unsigned16BitIntegerBuf patchBuffer(int[][] 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 Unsigned16BitIntegerBuf[] patchBuffers(int[][] 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 Unsigned16BitIntegerBuf buffer(SharedInteger item)
item - SharedInteger object that wraps the item.
NullPointerException - (unchecked exception) Thrown if item is null.public static Unsigned16BitIntegerBuf buffer(SharedIntegerArray theArray)
theArray - Array.
NullPointerException - (unchecked exception) Thrown if theArray is null.
public static Unsigned16BitIntegerBuf sliceBuffer(SharedIntegerArray 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 Unsigned16BitIntegerBuf[] sliceBuffers(SharedIntegerArray 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 int 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,
int 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 Integer. If the item is null, 0 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(Unsigned16BitIntegerBuf theSrc,
Unsigned16BitIntegerBuf 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 | |||||||||