RTI Connext Java API
Version 5.0.0
|
Public Member Functions | |
final Class | getElementType () |
void | loan (Object buffer, int new_length) |
Loan a contiguous buffer to this sequence. | |
void | unloan () |
Return the loaned buffer in the sequence and set the maximum to 0. | |
final boolean | hasOwnership () |
Return the value of the owned flag. | |
final void | clear () |
final void | setSize (int newSize) |
final int | size () |
final Object | copy_from (Object src) |
Public Member Functions inherited from AbstractSequence | |
void | add (int index, Object element) |
Inserts the specified element at the specified position in this sequence. | |
boolean | add (Object element) |
Appends the specified element to the end of this sequence. | |
final Object | remove (int index) |
Remove the element at the given index by shifting all subsequent elements "left" by one. | |
Public Member Functions inherited from Sequence | |
int | getMaximum () |
Get the current maximum number of elements that can be stored in this sequence. | |
void | setMaximum (int new_max) |
Resize this sequence to a new desired maximum. | |
Class | getElementType () |
A base class for sequences whose elements are of primitive types. Such sequences do not support null values.
final Class getElementType | ( | ) |
void loan | ( | Object | buffer, |
int | new_length | ||
) |
Loan a contiguous buffer to this sequence.
This operation changes the owned
flag of the sequence to com.rti.dds.infrastructure.false and also sets the underlying buffer used by the sequence. See the User's Manual for more information about sequences and memory ownership.
Use this method if you want to manage the memory used by the sequence yourself. You must provide an array of elements and integers indicating how many elements are allocated in that array (i.e. the maximum) and how many elements are valid (i.e. the length). The sequence will subsequently use the memory you provide and will not permit it to be freed by a call to com.rti.dds.infrastructure.com.rti.dds.util.Sequence.Sequence.setMaximum.
By default, a sequence you create owns its memory unless you explicitly loan memory of your own to it. In a very few cases, RTI Connext will return a sequence to you that has a loan; those cases are documented as such. For example, if you call com.rti.ndds.example.FooDataReader.read or com.rti.ndds.example.FooDataReader.take and pass in sequences with no loan and no memory allocated, RTI Connext will loan memory to your sequences which must be unloaned with com.rti.ndds.example.FooDataReader.return_loan. See the documentation of those methods for more information.
buffer | The new buffer that the sequence will use. Must point to enough memory to hold new_max elements of type Foo. It may be NULL if new_max == 0. |
new_length | The desired new length for the sequence. |
buffer
is successfully loaned to this sequence or com.rti.dds.infrastructure.false otherwise. Failure only occurs due to failing to meet the pre-conditions. Upon failure the sequence remains unmodified. void unloan | ( | ) |
Return the loaned buffer in the sequence and set the maximum to 0.
This method affects only the state of this sequence; it does not change the contents of the buffer in any way.
Only the user who originally loaned a buffer should return that loan, as the user may have dependencies on that memory known only to them. Unloaning someone else's buffer may cause unspecified problems. For example, suppose a sequence is loaning memory from a custom memory pool. A user of the sequence likely has no way to release the memory back into the pool, so unloaning the sequence buffer would result in a resource leak. If the user were to then re-loan a different buffer, the original creator of the sequence would have no way to discover, when freeing the sequence, that the loan no longer referred to its own memory and would thus not free the user's memory properly, exacerbating the situation and leading to undefined behavior.
final boolean hasOwnership | ( | ) |
Return the value of the owned flag.
final void clear | ( | ) |
Set the logical size of this sequence to zero. This method does not generate any garbage for collection.
final void setSize | ( | int | newSize | ) |
Set the logical size of this sequence to the given value.
newSize | the new logical size of this sequence; it must be less than or equal to the maximum allocated length of the underlying array. |
IndexOutOfBoundsException | if the new size is less than zero or greater than the allocated length of the array. |
final int size | ( | ) |
The logical size of this sequence.
final Object copy_from | ( | Object | src | ) |
Implementation of the Copyable
interface.
src | An AbstractPrimitiveSequence which contains the data to be copied. |
this