activemq-cpp-3.4.0
|
This class defines four categories of operations upon int buffers: More...
#include <src/main/decaf/nio/IntBuffer.h>
Public Member Functions | |
virtual | ~IntBuffer () |
virtual std::string | toString () const |
virtual int * | array ()=0 |
Returns the int array that backs this buffer (optional operation). | |
virtual int | arrayOffset ()=0 |
Returns the offset within this buffer's backing array of the first element of the buffer (optional operation). | |
virtual IntBuffer * | asReadOnlyBuffer () const =0 |
Creates a new, read-only int buffer that shares this buffer's content. | |
virtual IntBuffer & | compact ()=0 |
Compacts this buffer. | |
virtual IntBuffer * | duplicate ()=0 |
Creates a new int buffer that shares this buffer's content. | |
virtual int | get ()=0 |
Relative get method. | |
virtual int | get (int index) const =0 |
Absolute get method. | |
IntBuffer & | get (std::vector< int > buffer) |
Relative bulk get method. | |
IntBuffer & | get (int *buffer, int size, int offset, int length) |
Relative bulk get method. | |
virtual bool | hasArray () const =0 |
Tells whether or not this buffer is backed by an accessible int array. | |
IntBuffer & | put (IntBuffer &src) |
This method transfers the ints remaining in the given source buffer into this buffer. | |
IntBuffer & | put (const int *buffer, int size, int offset, int length) |
This method transfers ints into this buffer from the given source array. | |
IntBuffer & | put (std::vector< int > &buffer) |
This method transfers the entire content of the given source ints array into this buffer. | |
virtual IntBuffer & | put (int value)=0 |
Writes the given integer into this buffer at the current position, and then increments the position. | |
virtual IntBuffer & | put (int index, int value)=0 |
Writes the given ints into this buffer at the given index. | |
virtual IntBuffer * | slice () const =0 |
Creates a new IntBuffer whose content is a shared subsequence of this buffer's content. | |
virtual int | compareTo (const IntBuffer &value) const |
| |
virtual bool | equals (const IntBuffer &value) const |
| |
virtual bool | operator== (const IntBuffer &value) const |
| |
virtual bool | operator< (const IntBuffer &value) const |
| |
Static Public Member Functions | |
static IntBuffer * | allocate (int capacity) |
Allocates a new Double buffer. | |
static IntBuffer * | wrap (int *array, int size, int offset, int length) |
Wraps the passed buffer with a new IntBuffer. | |
static IntBuffer * | wrap (std::vector< int > &buffer) |
Wraps the passed STL int Vector in a IntBuffer. | |
Protected Member Functions | |
IntBuffer (int capacity) | |
Creates a IntBuffer object that has its backing array allocated internally and is then owned and deleted when this object is deleted. |
This class defines four categories of operations upon int buffers:
o Absolute and relative get and put methods that read and write single ints; o Relative bulk get methods that transfer contiguous sequences of ints from this buffer into an array; and o Relative bulk put methods that transfer contiguous sequences of ints from a int array or some other int buffer into this buffer o Methods for compacting, duplicating, and slicing a int buffer.
Double buffers can be created either by allocation, which allocates space for the buffer's content, by wrapping an existing int array into a buffer, or by creating a view of an existing byte buffer
Methods in this class that do not otherwise have a value to return are specified to return the buffer upon which they are invoked. This allows method invocations to be chained.
decaf::nio::IntBuffer::IntBuffer | ( | int | capacity | ) | [protected] |
Creates a IntBuffer object that has its backing array allocated internally and is then owned and deleted when this object is deleted.
The array is initially created with all elements initialized to zero.
capacity | The size and limit of the Buffer in integers. |
IllegalArguementException | if capacity is negative. |
virtual decaf::nio::IntBuffer::~IntBuffer | ( | ) | [inline, virtual] |
static IntBuffer* decaf::nio::IntBuffer::allocate | ( | int | capacity | ) | [static] |
Allocates a new Double buffer.
The new buffer's position will be zero, its limit will be its capacity, and its mark will be undefined. It will have a backing array, and its array offset will be zero.
capacity | The size of the Double buffer in integers. |
virtual int* decaf::nio::IntBuffer::array | ( | ) | [pure virtual] |
Returns the int array that backs this buffer (optional operation).
Modifications to this buffer's content will cause the returned array's content to be modified, and vice versa.
Invoke the hasArray method before invoking this method in order to ensure that this buffer has an accessible backing array.
ReadOnlyBufferException | if this Buffer is read only. |
UnsupportedOperationException | if the underlying store has no array. |
Implemented in decaf::internal::nio::IntArrayBuffer.
virtual int decaf::nio::IntBuffer::arrayOffset | ( | ) | [pure virtual] |
Returns the offset within this buffer's backing array of the first element of the buffer (optional operation).
Invoke the hasArray method before invoking this method in order to ensure that this buffer has an accessible backing array.
ReadOnlyBufferException | if this Buffer is read only. |
UnsupportedOperationException | if the underlying store has no array. |
Implemented in decaf::internal::nio::IntArrayBuffer.
virtual IntBuffer* decaf::nio::IntBuffer::asReadOnlyBuffer | ( | ) | const [pure virtual] |
Creates a new, read-only int buffer that shares this buffer's content.
The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer; the new buffer itself, however, will be read-only and will not allow the shared content to be modified. The two buffers' position, limit, and mark values will be independent.
If this buffer is itself read-only then this method behaves in exactly the same way as the duplicate method.
The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer.
Implemented in decaf::internal::nio::IntArrayBuffer.
virtual IntBuffer& decaf::nio::IntBuffer::compact | ( | ) | [pure virtual] |
Compacts this buffer.
The bytes between the buffer's current position and its limit, if any, are copied to the beginning of the buffer. That is, the byte at index p = position() is copied to index zero, the byte at index p + 1 is copied to index one, and so forth until the byte at index limit() - 1 is copied to index n = limit() - 1 - p. The buffer's position is then set to n+1 and its limit is set to its capacity. The mark, if defined, is discarded.
The buffer's position is set to the number of bytes copied, rather than to zero, so that an invocation of this method can be followed immediately by an invocation of another relative put method.
ReadOnlyBufferException | if this buffer is read-only. |
Implemented in decaf::internal::nio::IntArrayBuffer.
virtual int decaf::nio::IntBuffer::compareTo | ( | const IntBuffer & | value | ) | const [virtual] |
virtual IntBuffer* decaf::nio::IntBuffer::duplicate | ( | ) | [pure virtual] |
Creates a new int buffer that shares this buffer's content.
The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer. The new buffer will be read-only if, and only if, this buffer is read-only.
Implemented in decaf::internal::nio::IntArrayBuffer.
virtual bool decaf::nio::IntBuffer::equals | ( | const IntBuffer & | value | ) | const [virtual] |
IntBuffer& decaf::nio::IntBuffer::get | ( | std::vector< int > | buffer | ) |
Relative bulk get method.
This method transfers values from this buffer into the given destination vector. An invocation of this method of the form src.get(a) behaves in exactly the same way as the invocation. The vector must be sized to the amount of data that is to be read, that is to say, the caller should call buffer.resize( N ) before calling this get method.
BufferUnderflowException | if there are fewer than length ints remaining in this buffer. |
virtual int decaf::nio::IntBuffer::get | ( | int | index | ) | const [pure virtual] |
Absolute get method.
Reads the value at the given index.
index | The index in the Buffer where the int is to be read. |
IndexOutOfBoundsException | if index is not smaller than the buffer's limit, or index is negative. |
Implemented in decaf::internal::nio::IntArrayBuffer.
IntBuffer& decaf::nio::IntBuffer::get | ( | int * | buffer, |
int | size, | ||
int | offset, | ||
int | length | ||
) |
Relative bulk get method.
This method transfers ints from this buffer into the given destination array. If there are fewer ints remaining in the buffer than are required to satisfy the request, that is, if length > remaining(), then no bytes are transferred and a BufferUnderflowException is thrown.
Otherwise, this method copies length ints from this buffer into the given array, starting at the current position of this buffer and at the given offset in the array. The position of this buffer is then incremented by length.
buffer | The pointer to an allocated buffer to fill. |
size | The size of the buffer that was passed in. |
offset | The position in the buffer to start filling. |
length | The amount of data to put in the passed buffer. |
BufferUnderflowException | if there are fewer than length ints remaining in this buffer. |
NullPointerException | if the passed buffer is null. |
IndexOutOfBoundsException | if the preconditions of size, offset, or length are not met. |
virtual int decaf::nio::IntBuffer::get | ( | ) | [pure virtual] |
Relative get method.
Reads the value at this buffer's current position, and then increments the position.
BufferUnderflowException | if there no more data to return. |
Implemented in decaf::internal::nio::IntArrayBuffer.
virtual bool decaf::nio::IntBuffer::hasArray | ( | ) | const [pure virtual] |
Tells whether or not this buffer is backed by an accessible int array.
If this method returns true then the array and arrayOffset methods may safely be invoked. Subclasses should override this method if they do not have a backing array as this class always returns true.
Implemented in decaf::internal::nio::IntArrayBuffer.
virtual bool decaf::nio::IntBuffer::operator< | ( | const IntBuffer & | value | ) | const [virtual] |
virtual bool decaf::nio::IntBuffer::operator== | ( | const IntBuffer & | value | ) | const [virtual] |
virtual IntBuffer& decaf::nio::IntBuffer::put | ( | int | value | ) | [pure virtual] |
Writes the given integer into this buffer at the current position, and then increments the position.
value | The integer value to be written. |
BufferOverflowException | if this buffer's current position is not smaller than its limit. |
ReadOnlyBufferException | if this buffer is read-only. |
Implemented in decaf::internal::nio::IntArrayBuffer.
virtual IntBuffer& decaf::nio::IntBuffer::put | ( | int | index, |
int | value | ||
) | [pure virtual] |
Writes the given ints into this buffer at the given index.
index | The position in the Buffer to write the data. |
value | The ints to write. |
IndexOutOfBoundsException | - If index greater than the buffer's limit minus the size of the type being written, or the index is negative. |
ReadOnlyBufferException | - If this buffer is read-only. |
Implemented in decaf::internal::nio::IntArrayBuffer.
IntBuffer& decaf::nio::IntBuffer::put | ( | const int * | buffer, |
int | size, | ||
int | offset, | ||
int | length | ||
) |
This method transfers ints into this buffer from the given source array.
If there are more ints to be copied from the array than remain in this buffer, that is, if length > remaining(), then no ints are transferred and a BufferOverflowException is thrown.
Otherwise, this method copies length bytes from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length.
buffer | The array from which integers are to be read. |
size | The size of the buffer passed. |
offset | The offset within the array of the first char to be read. |
length | The number of integers to be read from the given array. |
BufferOverflowException | if there is insufficient space in this buffer. |
ReadOnlyBufferException | if this buffer is read-only. |
NullPointerException | if the passed buffer is null. |
IndexOutOfBoundsException | if the preconditions of size, offset, or length are not met. |
IntBuffer& decaf::nio::IntBuffer::put | ( | std::vector< int > & | buffer | ) |
This method transfers the entire content of the given source ints array into this buffer.
This is the same as calling put( &buffer[0], 0, buffer.size().
buffer | The buffer whose contents are copied to this IntBuffer. |
BufferOverflowException | if there is insufficient space in this buffer. |
ReadOnlyBufferException | if this buffer is read-only. |
This method transfers the ints remaining in the given source buffer into this buffer.
If there are more ints remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no ints are transferred and a BufferOverflowException is thrown.
Otherwise, this method copies n = src.remaining() ints from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.
src | The buffer to take ints from an place in this one. |
BufferOverflowException | if there is insufficient space in this buffer for the remaining ints in the source buffer. |
IllegalArgumentException | if the source buffer is this buffer. |
ReadOnlyBufferException | if this buffer is read-only. |
virtual IntBuffer* decaf::nio::IntBuffer::slice | ( | ) | const [pure virtual] |
Creates a new IntBuffer whose content is a shared subsequence of this buffer's content.
The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer, and its mark will be undefined. The new buffer will be read-only if, and only if, this buffer is read-only.
Implemented in decaf::internal::nio::IntArrayBuffer.
virtual std::string decaf::nio::IntBuffer::toString | ( | ) | const [virtual] |
static IntBuffer* decaf::nio::IntBuffer::wrap | ( | int * | array, |
int | size, | ||
int | offset, | ||
int | length | ||
) | [static] |
Wraps the passed buffer with a new IntBuffer.
The new buffer will be backed by the given int array; that is, modifications to the buffer will cause the array to be modified and vice versa. The new buffer's capacity will be array.length, its position will be offset, its limit will be offset + length, and its mark will be undefined. Its backing array will be the given array, and its array offset will be zero.
array | The array that will back the new buffer. |
size | The size of the passed in array. |
offset | The offset of the subarray to be used. |
length | The length of the subarray to be used. |
NullPointerException | if the array pointer is NULL. |
IndexOutOfBoundsException | if the preconditions of size, offset, or length are not met. |
static IntBuffer* decaf::nio::IntBuffer::wrap | ( | std::vector< int > & | buffer | ) | [static] |
Wraps the passed STL int Vector in a IntBuffer.
The new buffer will be backed by the given int array; modifications to the buffer will cause the array to be modified and vice versa. The new buffer's capacity and limit will be buffer.size(), its position will be zero, and its mark will be undefined. Its backing array will be the given array, and its array offset will be zero.
buffer | The vector that will back the new buffer, the vector must have been sized to the desired size already by calling vector.resize( N ). |