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