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