IndexOutOfBoundsException. This class exists mostly to represent zero-length arrays,
and particularly, zero-length slices for which implementations of
PyBuffer#getBufferSlice(int, int, int, int) in any case need special logic. Bulk
operations like copyTo(byte[], int)) and toString() efficiently do nothing,
instead of calling complicated logic that finally does nothing.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | ZeroByteBuffer.
A |
| Modifier and Type | Field and Description |
|---|---|
| private static final byte[] | EMPTY
Shared instance of a zero-length storage. |
| Access | Constructor and Description |
|---|---|
| public | ZeroByteBuffer(int
consumer requirements flags, BufferProtocol exporting object (or obj, boolean null)set true if not to be considered writable readonly, boolean set true if to be considered as backed by an array hasArray)Construct an instance of a zero-length buffer, choosing whether it should report itself to be
read-only through |
| Modifier and Type | Method and Description |
|---|---|
| public int | byteIndex(int
item-index from consumer index)Overrides org. Implements org. In a ZeroByteBuffer, the index is always out of bounds. |
| public int | byteIndex(int...
n-dimensional item-index from consumer indices)Overrides org. Implements org. In a ZeroByteBuffer, if the dimensions are right, the index is out of bounds anyway. |
| public void | copyFrom(byte[]
source byte array src, int location in source of first byte to copy srcPos, int starting item-index in the destination (i.e. destIndex, int this)number of items to copy in count)Overrides org. Implements org. In a ZeroByteBuffer, there is no room for anything, so this throws unless the source count is zero. |
| public void | copyFrom(PyBuffer
source buffer src)Overrides org. Implements org. In a ZeroByteBuffer, there is no room for anything, so this throws unless the source count is zero. |
| public void | copyTo(byte[]
destination byte array dest, int byte-index in the destination array of the byte [0] destPos)Overrides org. Implements org. Copy the contents of the buffer to the destination byte array. |
| public void | copyTo(int
starting item-index in the source buffer srcIndex, byte[] destination byte array dest, int byte-index in the destination array of the source item [0,...] destPos, int number of items to copy count)Overrides org. Implements org. Copy a simple slice of the buffer-view to the destination byte array, defined by a starting
item-index in the source buffer and the |
| public PyBuffer. | getBuf()
Overrides org. Implements org.
References Deprecated
PyBuffer.Pointer is deprecated or references (maybe indirectly) at least one deprecated element.
Return a structure describing the slice of a byte array that holds the data being exported to the consumer. |
| public PyBuffer | getBufferSlice(int
specifying features demanded and the navigational capabilities of the consumer flags, int index in the current buffer start, int number of items in the required slice count)Overrides org. Implements org. Only a zero-length slice at zero is valid (in which case, the present buffer will do nicely as a result, with the export count incremented. |
| public PyBuffer | getBufferSlice(int
specifying features demanded and the navigational capabilities of the consumer flags, int index in the current buffer start, int number of items in the required slice count, int index-distance in the current buffer between consecutive items in the slice stride)Implements org. Only a zero-length slice at zero is valid (in which case, the present buffer will do nicely as a result, with the export count incremented. |
| public int | getLen()
Overrides org. Implements org. The total number of bytes represented by the view, which will be the product of the elements
of the |
| public String | toString()
Overrides org. Implements org. For a ZeroByteBuffer, it's the empty string. |
| EMPTY | back to summary |
|---|---|
| private static final byte[] EMPTY Shared instance of a zero-length storage. | |
| ZeroByteBuffer | back to summary |
|---|---|
| public ZeroByteBuffer(int flags, BufferProtocol obj, boolean readonly, boolean hasArray) throws PyException Construct an instance of a zero-length buffer, choosing whether it should report itself to be
read-only through
| |
| byteIndex | back to summary |
|---|---|
| public int byteIndex(int index) throws IndexOutOfBoundsException Overrides org. Implements org. In a ZeroByteBuffer, the index is always out of bounds.
| |
| byteIndex | back to summary |
|---|---|
| public int byteIndex(int... indices) throws IndexOutOfBoundsException Overrides org. Implements org. In a ZeroByteBuffer, if the dimensions are right, the index is out of bounds anyway.
| |
| copyFrom | back to summary |
|---|---|
| public void copyFrom(byte[] src, int srcPos, int destIndex, int count) throws IndexOutOfBoundsException, PyException Overrides org. Implements org. In a ZeroByteBuffer, there is no room for anything, so this throws unless the source count is zero.
| |
| copyFrom | back to summary |
|---|---|
| public void copyFrom(PyBuffer src) throws IndexOutOfBoundsException, PyException Overrides org. Implements org. In a ZeroByteBuffer, there is no room for anything, so this throws unless the source count is zero.
| |
| copyTo | back to summary |
|---|---|
| public void copyTo(byte[] dest, int destPos) throws IndexOutOfBoundsException Overrides org. Implements org. Doc from org. Copy the contents of the buffer to the destination byte array. The number of bytes will be
that returned by
The default implementation in In a ZeroByteBuffer, there is simply nothing to copy.
| |
| copyTo | back to summary |
|---|---|
| public void copyTo(int srcIndex, byte[] dest, int destPos, int count) throws IndexOutOfBoundsException, PyException Overrides org. Implements org. Doc from org. Copy a simple slice of the buffer-view to the destination byte array, defined by a starting
item-index in the source buffer and the
The default implementation in
The implementation in In a ZeroByteBuffer, there is simply nothing to copy.
| |
| getBuf | back to summary |
|---|---|
| public PyBuffer. Overrides org. Implements org. Doc from org. References Deprecated
See corresponding docs for further information. Return a structure describing the slice of a byte array that holds the data being exported to
the consumer. For a one-dimensional contiguous buffer, assuming the following client code
where PyBuffer a = obj.getBuffer(PyBUF.SIMPLE); int itemsize = a.getItemsize(); PyBuffer.Pointer b = a.getBuf();the item with index k is in the array b.storage at index
[b.offset + k*itemsize] to [b.offset + (k+1)*itemsize - 1]
inclusive. And if itemsize==1, the item is simply the byte
b.storage[b.offset + k]
If the buffer is multidimensional or non-contiguous,
The implementation in
| |
| getBufferSlice | back to summary |
|---|---|
| public PyBuffer getBufferSlice(int flags, int start, int count) Overrides org. Implements org. Only a zero-length slice at zero is valid (in which case, the present buffer will do nicely as a result, with the export count incremented.
| |
| getBufferSlice | back to summary |
|---|---|
| public PyBuffer getBufferSlice(int flags, int start, int count, int stride) Implements org. Only a zero-length slice at zero is valid (in which case, the present buffer will do nicely as a result, with the export count incremented.
| |
| getLen | back to summary |
|---|---|
| public int getLen() Overrides org. Implements org. Doc from org. The total number of bytes represented by the view, which will be the product of the elements
of the
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Implements org. For a ZeroByteBuffer, it's the empty string.
| |
ZeroByteBuffer.View represents a contiguous subsequence of another
PyBuffer. We don't need it to make slices of the ZeroByteBuffer itself, but it
is useful for making zero-length slices of anything else. Lock-release semantics must still
be observed. In Python, a zero-length slice obtained from the memoryview of a bytearray still
counts as an export from the bytearray.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv PyBuffer | root
The buffer on which this is a slice view |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected PyBuffer | getRoot()
Overrides org. Some |
| root | back to summary |
|---|---|
| pack-priv PyBuffer root The buffer on which this is a slice view | |
| View | back to summary |
|---|---|
| public View(PyBuffer root, int flags) Construct a slice of a ZeroByteBuffer, which it goes without saying is of zero length at position zero.
| |
| getRoot | back to summary |
|---|---|
| protected PyBuffer getRoot() Overrides org. Doc from org. Some | |