CoreDX Data Distribution Service
The High Performance, Small Footprint DDS from Twin Oaks Computing, Inc
DDS::sequence< T > Class Template Reference

Sequence data type. More...

Inherited by DDS::bounded_sequence< T, BOUND >.

Public Member Functions

 sequence ()
 construct an empty sequence
 
 sequence (const sequence &x)
 copy constructor Copies sequence contents.
 
 ~sequence ()
 destroy the sequence and release resources. Destroys sequence contents.
 
sequenceoperator= (const sequence &x)
 assignment operator Copies seqeuence contents.
 
uint32_t size () const
 Returns the current size (number of elements) of the sequence.
 
uint32_t length () const
 alias for size()
 
uint32_t capacity () const
 Returns the current capacity (number of elements) of the sequence. The equation "size <= capacity" is always true.
 
bool reserve (uint32_t n)
 Set the capacity of the sequence. More...
 
bool resize (uint32_t n)
 Set the 'capacity' and 'size' of the sequence. More...
 
void maximum (uint32_t n)
 set the 'maximum' length of the sequence
 
uint32_t maximum () const
 set the 'maximum' length of the sequence
 
bool empty () const
 test if the sequence is empty
 
void shrink_to_fit ()
 reduce 'capacity' to match 'size'
 
void assign (T *buffer, uint32_t n)
 Caller provides an array of elements of size 'n'. The Sequence takes ownership of the memory. Note, 'buffer' must be allocated via new[].
 
T * release ()
 Release current sequence contents, caller takes ownership of the memory. If successful, the sequence is empty after this operation.
 
T & operator[] (uint32_t n)
 
const T & operator[] (uint32_t n) const
 
T & at (uint32_t n)
 
const T & at (uint32_t n) const
 
T & front ()
 
const T & front () const
 
T & back ()
 
const T & back () const
 
const T * buffer () const
 
bool push_back (const T &v)
 
void pop_back ()
 
void swap (sequence &x)
 
void clear ()
 

Detailed Description

template<class T>
class DDS::sequence< T >

Sequence data type.

Provides an implementation of the Sequence data type. This data type is used in a few places throughout the DDS API.

It is most prevelant in the DataReader API where it is used to return a collection of samples and SampleInfo items back to the caller.

It is also used in a few QoS Policies.

Member Function Documentation

◆ at() [1/2]

template<class T >
T & DDS::sequence< T >::at ( uint32_t  n)

access an element

◆ at() [2/2]

template<class T >
const T & DDS::sequence< T >::at ( uint32_t  n) const

access an element

◆ back() [1/2]

template<class T >
T & DDS::sequence< T >::back ( )

access the last element

◆ back() [2/2]

template<class T >
const T & DDS::sequence< T >::back ( ) const

access the last element

◆ buffer()

template<class T >
const T * DDS::sequence< T >::buffer ( ) const

get access to underlying buffer

◆ clear()

template<class T >
void DDS::sequence< T >::clear ( )

clear the contents of this sequence

◆ front() [1/2]

template<class T >
T & DDS::sequence< T >::front ( )

access the first element

◆ front() [2/2]

template<class T >
const T & DDS::sequence< T >::front ( ) const

access the first element

◆ operator[]() [1/2]

template<class T >
T & DDS::sequence< T >::operator[] ( uint32_t  n)

access an element

◆ operator[]() [2/2]

template<class T >
const T & DDS::sequence< T >::operator[] ( uint32_t  n) const

access an element

◆ pop_back()

template<class T >
void DDS::sequence< T >::pop_back ( )

reduce 'size' by one

◆ push_back()

template<class T>
bool DDS::sequence< T >::push_back ( const T &  v)

add an element after the last Increments 'size' (and possibly 'capacity') if requried.

Return values
trueif element is added
falseif element is not added (exceeded maximum bound, or out of memory)

◆ reserve()

template<class T >
bool DDS::sequence< T >::reserve ( uint32_t  n)

Set the capacity of the sequence.

If n is larger than current capacity, then the capacity is increased to 'n'. If 'n' is smaller than current capacity, then the capacity is reduced to 'n'. If capacity is reduced below 'size', then 'size' will be reduced to match 'capacity'. In the case of a reduction in 'size', the eliminated elements will be destroyed. If the requested capacity exceeds the maximum bound of the sequence, then the call fails and returns false. If the requested capacity is unattainable due to resource limits (eg, out of memory) then the call fails and returns false.

◆ resize()

template<class T >
bool DDS::sequence< T >::resize ( uint32_t  n)

Set the 'capacity' and 'size' of the sequence.

If n is larger than current capacity, then the capacity is increased to 'n'. If 'n' is smaller than current capacity, then the capacity is reduced to 'n'. If capacity is reduced below 'size', then 'size' will be reduced to match 'capacity'. In the case of a reduction in 'size', the eliminated elements will be destroyed.

◆ swap()

template<class T >
void DDS::sequence< T >::swap ( sequence< T > &  x)

swap the contents of this sequence with that of another


© 2009-2020 Twin Oaks Computing, Inc
Castle Rock, CO 80104
All rights reserved.