RTI Connext Modern C++ API  Version 5.3.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rti::core::bounded_sequence< T, MaxLength > Class Template Reference

<<value-type>> A bounded sequence of elements More...

#include <rti/core/BoundedSequence.hpp>

Public Types

typedef std::vector< T > vector_type
 The type of the underlying vector.
 
typedef vector_type::value_type value_type
 The type of the elements, T.
 
typedef vector_type::allocator_type allocator_type
 The allocator type of the underlying vector.
 
typedef vector_type::size_type size_type
 The size type.
 
typedef
vector_type::difference_type 
difference_type
 The difference type.
 
typedef vector_type::reference reference
 The reference type.
 
typedef
vector_type::const_reference 
const_reference
 The const reference type.
 
typedef vector_type::pointer pointer
 The pointer type.
 
typedef vector_type::const_pointer const_pointer
 The const pointer type.
 
typedef vector_type::iterator iterator
 The iterator type.
 
typedef vector_type::const_iterator const_iterator
 The const iterator type.
 
typedef
vector_type::reverse_iterator 
reverse_iterator
 The reverse iterator type.
 
typedef
vector_type::const_reverse_iterator 
const_reverse_iterator
 The const reverse iterator type.
 

Public Member Functions

 bounded_sequence ()
 Creates an empty bounded_sequence.
 
 bounded_sequence (const bounded_sequence &other)
 Copy constructor.
 
template<size_t M>
 bounded_sequence (const bounded_sequence< T, M > &other)
 Copies a bounded sequence with a different bound M.
 
 bounded_sequence (size_type count)
 Create a bounded_sequence with a number of default-construced elements.
 
 bounded_sequence (size_type count, const value_type &value)
 Create a bounded_sequence with a number of elements.
 
template<typename InputIt >
 bounded_sequence (InputIt first, InputIt last)
 Create a bounded_sequence from a range of elements.
 
 bounded_sequence (const std::vector< T > &v)
 Create a bounded_sequence copying the elements of a std::vector.
 
 bounded_sequence (bounded_sequence &&other) OMG_NOEXCEPT
 <<C++11>> Move constructor
 
 bounded_sequence (std::vector< T > &&v)
 <<C++11>> Creates a bounded_sequence by moving a std::vector
 
bounded_sequenceoperator= (const bounded_sequence &other)
 Assignment operator.
 
template<typename U , size_t M>
bounded_sequenceoperator= (const bounded_sequence< U, M > &other)
 Copies the elements of a sequence with a different bound.
 
bounded_sequenceoperator= (const std::vector< T > &v)
 Copies the elements of a std::vector.
 
bounded_sequenceoperator= (bounded_sequence &&other) OMG_NOEXCEPT
 <<C++11>> Move-assignment operator
 
bounded_sequenceoperator= (std::vector< T > &&v)
 <<C++11>> Moves a std::vector into this bounded_sequence
 
reference operator[] (size_type pos)
 Index access.
 
const_reference operator[] (size_type pos) const
 Index access.
 
reference at (size_type pos)
 Index access with bounds check.
 
const_reference at (size_type pos) const
 Index access with bounds check.
 
reference front ()
 Returns a reference to the first element.
 
const_reference front () const
 Returns a const reference to the first element.
 
reference back ()
 Returns a reference to the last element.
 
const_reference back () const
 Returns a const reference to the last element.
 
pointer data ()
 Returns a pointer to the underlying data buffer.
 
const_pointer data () const
 Returns a pointer to the underlying data buffer.
 
iterator begin () OMG_NOEXCEPT
 Returns an iterator to the first element.
 
const_iterator begin () const OMG_NOEXCEPT
 Returns an const iterator to the first element.
 
const_iterator cbegin () const OMG_NOEXCEPT
 Returns an const iterator to the first element.
 
iterator end () OMG_NOEXCEPT
 Returns an iterator to one past the last element.
 
const_iterator end () const OMG_NOEXCEPT
 Returns an const iterator to one past the last element.
 
const_iterator cend () const OMG_NOEXCEPT
 Returns a const iterator to one past the last element.
 
reverse_iterator rbegin () OMG_NOEXCEPT
 Returns an iterator to the reverse-beginning of the sequence.
 
const_reverse_iterator rbegin () const OMG_NOEXCEPT
 Returns a const iterator to the reverse-beginning of the sequence.
 
const_reverse_iterator crbegin () const OMG_NOEXCEPT
 Returns a const iterator to the reverse-beginning of the sequence.
 
reverse_iterator rend () OMG_NOEXCEPT
 Returns an iterator to the reverse-end of the sequence.
 
const_reverse_iterator crend () const OMG_NOEXCEPT
 Returns a const iterator to the reverse-end of the sequence.
 
bool empty () const OMG_NOEXCEPT
 Returns whether there are no elements.
 
size_type size () const OMG_NOEXCEPT
 Returns the number of elements.
 
size_type max_size () const OMG_NOEXCEPT
 Returns MaxLength.
 
void reserve (size_type new_capacity)
 Pre-allocates elements up to new_capacity.
 
size_type capacity () const OMG_NOEXCEPT
 Returns the current capacity.
 
void clear () OMG_NOEXCEPT
 Removes the elements.
 
void shrink_to_fit ()
 Destroys any extra elements reserved above the current size.
 
iterator insert (iterator pos, const T &value)
 Inserts a new element in a position specified by an iterator.
 
iterator erase (iterator pos)
 Erases an element specified by an iterator.
 
void push_back (const T &value)
 Adds a new element at the end.
 
void push_back (T &&value)
 Adds a new element at the end by moving it.
 
void pop_back ()
 Removes the last element.
 
void resize (size_type count)
 Resizes the container to contain count elements.
 
void resize (size_type count, const T &value)
 Resizes the container to contain count elements.
 
void swap (bounded_sequence &other) OMG_NOEXCEPT
 Swap the contents of two sequences.
 

Detailed Description

template<typename T, size_t MaxLength>
class rti::core::bounded_sequence< T, MaxLength >

<<value-type>> A bounded sequence of elements

Template Parameters
TThe element type
MaxLengthThe maximum number of elements

IDL bounded sequences map to this type, as described in Working with IDL types.

This type has a interface similar to std::vector, but it differs in two aspects:

  • it implements a different element life-cycle strategy that optimizes the performance of the internal dds::sub::DataReader and dds::pub::DataWriter serialization operations. Just like a std::vector, a bounded_sequence has a size and a capacity. But when capacity > size, the extra elements are default-constructed, unlike a std::vector where the extra elements are uninitialized memory. Functions that reduce the size of the sequence do not destroy the elements that they remove. Only shrink_to_fit() does.
See Also
Working with IDL types.

Member Typedef Documentation

template<typename T , size_t MaxLength>
typedef std::vector<T> rti::core::bounded_sequence< T, MaxLength >::vector_type

The type of the underlying vector.

template<typename T , size_t MaxLength>
typedef vector_type::value_type rti::core::bounded_sequence< T, MaxLength >::value_type

The type of the elements, T.

template<typename T , size_t MaxLength>
typedef vector_type::allocator_type rti::core::bounded_sequence< T, MaxLength >::allocator_type

The allocator type of the underlying vector.

template<typename T , size_t MaxLength>
typedef vector_type::size_type rti::core::bounded_sequence< T, MaxLength >::size_type

The size type.

template<typename T , size_t MaxLength>
typedef vector_type::difference_type rti::core::bounded_sequence< T, MaxLength >::difference_type

The difference type.

template<typename T , size_t MaxLength>
typedef vector_type::reference rti::core::bounded_sequence< T, MaxLength >::reference

The reference type.

template<typename T , size_t MaxLength>
typedef vector_type::const_reference rti::core::bounded_sequence< T, MaxLength >::const_reference

The const reference type.

template<typename T , size_t MaxLength>
typedef vector_type::pointer rti::core::bounded_sequence< T, MaxLength >::pointer

The pointer type.

template<typename T , size_t MaxLength>
typedef vector_type::const_pointer rti::core::bounded_sequence< T, MaxLength >::const_pointer

The const pointer type.

template<typename T , size_t MaxLength>
typedef vector_type::iterator rti::core::bounded_sequence< T, MaxLength >::iterator

The iterator type.

template<typename T , size_t MaxLength>
typedef vector_type::const_iterator rti::core::bounded_sequence< T, MaxLength >::const_iterator

The const iterator type.

template<typename T , size_t MaxLength>
typedef vector_type::reverse_iterator rti::core::bounded_sequence< T, MaxLength >::reverse_iterator

The reverse iterator type.

template<typename T , size_t MaxLength>
typedef vector_type::const_reverse_iterator rti::core::bounded_sequence< T, MaxLength >::const_reverse_iterator

The const reverse iterator type.

Constructor & Destructor Documentation

template<typename T , size_t MaxLength>
rti::core::bounded_sequence< T, MaxLength >::bounded_sequence ( )
inline

Creates an empty bounded_sequence.

template<typename T , size_t MaxLength>
rti::core::bounded_sequence< T, MaxLength >::bounded_sequence ( const bounded_sequence< T, MaxLength > &  other)
inline

Copy constructor.

template<typename T , size_t MaxLength>
template<size_t M>
rti::core::bounded_sequence< T, MaxLength >::bounded_sequence ( const bounded_sequence< T, M > &  other)
inlineexplicit

Copies a bounded sequence with a different bound M.

Exceptions
dds::core::PreconditionNotMetErrorif other.size() > MaxLength
template<typename T , size_t MaxLength>
rti::core::bounded_sequence< T, MaxLength >::bounded_sequence ( size_type  count)
inline

Create a bounded_sequence with a number of default-construced elements.

template<typename T , size_t MaxLength>
rti::core::bounded_sequence< T, MaxLength >::bounded_sequence ( size_type  count,
const value_type value 
)
inline

Create a bounded_sequence with a number of elements.

template<typename T , size_t MaxLength>
template<typename InputIt >
rti::core::bounded_sequence< T, MaxLength >::bounded_sequence ( InputIt  first,
InputIt  last 
)
inline

Create a bounded_sequence from a range of elements.

template<typename T , size_t MaxLength>
rti::core::bounded_sequence< T, MaxLength >::bounded_sequence ( const std::vector< T > &  v)
inline

Create a bounded_sequence copying the elements of a std::vector.

Exceptions
dds::core::PreconditionNotMetErrorif v.size() > MaxLength
template<typename T , size_t MaxLength>
rti::core::bounded_sequence< T, MaxLength >::bounded_sequence ( bounded_sequence< T, MaxLength > &&  other)
inline

<<C++11>> Move constructor

template<typename T , size_t MaxLength>
rti::core::bounded_sequence< T, MaxLength >::bounded_sequence ( std::vector< T > &&  v)
inline

<<C++11>> Creates a bounded_sequence by moving a std::vector

Member Function Documentation

template<typename T , size_t MaxLength>
bounded_sequence& rti::core::bounded_sequence< T, MaxLength >::operator= ( const bounded_sequence< T, MaxLength > &  other)
inline

Assignment operator.

template<typename T , size_t MaxLength>
template<typename U , size_t M>
bounded_sequence& rti::core::bounded_sequence< T, MaxLength >::operator= ( const bounded_sequence< U, M > &  other)
inline

Copies the elements of a sequence with a different bound.

Exceptions
dds::core::PreconditionNotMetErrorif other.size() > MaxLength
template<typename T , size_t MaxLength>
bounded_sequence& rti::core::bounded_sequence< T, MaxLength >::operator= ( const std::vector< T > &  v)
inline

Copies the elements of a std::vector.

template<typename T , size_t MaxLength>
bounded_sequence& rti::core::bounded_sequence< T, MaxLength >::operator= ( bounded_sequence< T, MaxLength > &&  other)
inline

<<C++11>> Move-assignment operator

template<typename T , size_t MaxLength>
bounded_sequence& rti::core::bounded_sequence< T, MaxLength >::operator= ( std::vector< T > &&  v)
inline

<<C++11>> Moves a std::vector into this bounded_sequence

template<typename T , size_t MaxLength>
reference rti::core::bounded_sequence< T, MaxLength >::operator[] ( size_type  pos)
inline

Index access.

template<typename T , size_t MaxLength>
const_reference rti::core::bounded_sequence< T, MaxLength >::operator[] ( size_type  pos) const
inline

Index access.

template<typename T , size_t MaxLength>
reference rti::core::bounded_sequence< T, MaxLength >::at ( size_type  pos)
inline

Index access with bounds check.

Exceptions
std::out_of_rangeif pos is >= size()
template<typename T , size_t MaxLength>
const_reference rti::core::bounded_sequence< T, MaxLength >::at ( size_type  pos) const
inline

Index access with bounds check.

Exceptions
std::out_of_rangeif pos is >= size()
template<typename T , size_t MaxLength>
reference rti::core::bounded_sequence< T, MaxLength >::front ( )
inline

Returns a reference to the first element.

template<typename T , size_t MaxLength>
const_reference rti::core::bounded_sequence< T, MaxLength >::front ( ) const
inline

Returns a const reference to the first element.

template<typename T , size_t MaxLength>
reference rti::core::bounded_sequence< T, MaxLength >::back ( )
inline

Returns a reference to the last element.

template<typename T , size_t MaxLength>
const_reference rti::core::bounded_sequence< T, MaxLength >::back ( ) const
inline

Returns a const reference to the last element.

template<typename T , size_t MaxLength>
pointer rti::core::bounded_sequence< T, MaxLength >::data ( )
inline

Returns a pointer to the underlying data buffer.

template<typename T , size_t MaxLength>
const_pointer rti::core::bounded_sequence< T, MaxLength >::data ( ) const
inline

Returns a pointer to the underlying data buffer.

template<typename T , size_t MaxLength>
iterator rti::core::bounded_sequence< T, MaxLength >::begin ( )
inline

Returns an iterator to the first element.

template<typename T , size_t MaxLength>
const_iterator rti::core::bounded_sequence< T, MaxLength >::begin ( ) const
inline

Returns an const iterator to the first element.

template<typename T , size_t MaxLength>
const_iterator rti::core::bounded_sequence< T, MaxLength >::cbegin ( ) const
inline

Returns an const iterator to the first element.

template<typename T , size_t MaxLength>
iterator rti::core::bounded_sequence< T, MaxLength >::end ( )
inline

Returns an iterator to one past the last element.

template<typename T , size_t MaxLength>
const_iterator rti::core::bounded_sequence< T, MaxLength >::end ( ) const
inline

Returns an const iterator to one past the last element.

template<typename T , size_t MaxLength>
const_iterator rti::core::bounded_sequence< T, MaxLength >::cend ( ) const
inline

Returns a const iterator to one past the last element.

template<typename T , size_t MaxLength>
reverse_iterator rti::core::bounded_sequence< T, MaxLength >::rbegin ( )
inline

Returns an iterator to the reverse-beginning of the sequence.

template<typename T , size_t MaxLength>
const_reverse_iterator rti::core::bounded_sequence< T, MaxLength >::rbegin ( ) const
inline

Returns a const iterator to the reverse-beginning of the sequence.

template<typename T , size_t MaxLength>
const_reverse_iterator rti::core::bounded_sequence< T, MaxLength >::crbegin ( ) const
inline

Returns a const iterator to the reverse-beginning of the sequence.

template<typename T , size_t MaxLength>
reverse_iterator rti::core::bounded_sequence< T, MaxLength >::rend ( )
inline

Returns an iterator to the reverse-end of the sequence.

template<typename T , size_t MaxLength>
const_reverse_iterator rti::core::bounded_sequence< T, MaxLength >::crend ( ) const
inline

Returns a const iterator to the reverse-end of the sequence.

template<typename T , size_t MaxLength>
bool rti::core::bounded_sequence< T, MaxLength >::empty ( ) const
inline

Returns whether there are no elements.

template<typename T , size_t MaxLength>
size_type rti::core::bounded_sequence< T, MaxLength >::size ( ) const
inline

Returns the number of elements.

template<typename T , size_t MaxLength>
size_type rti::core::bounded_sequence< T, MaxLength >::max_size ( ) const
inline

Returns MaxLength.

template<typename T , size_t MaxLength>
void rti::core::bounded_sequence< T, MaxLength >::reserve ( size_type  new_capacity)
inline

Pre-allocates elements up to new_capacity.

This operation reserves space for new_capacity elements and, unlike std::vector, it also default-constructs the extra elements. The size() remains the same.

template<typename T , size_t MaxLength>
size_type rti::core::bounded_sequence< T, MaxLength >::capacity ( ) const
inline

Returns the current capacity.

See Also
reserve()
template<typename T , size_t MaxLength>
void rti::core::bounded_sequence< T, MaxLength >::clear ( )
inline

Removes the elements.

This operation resizes the sequence to 0, but it doesn't destroy the elements, like std::vector would.

To destroy the elements, follow with a call to shrink_to_fit.

template<typename T , size_t MaxLength>
void rti::core::bounded_sequence< T, MaxLength >::shrink_to_fit ( )
inline

Destroys any extra elements reserved above the current size.

Note that resize() or clear() alone won't destroy the extra elements when they reduce the size of a sequence.

For example

bounded_sequence<Foo, 20> s;
s.resize(10); // 10 elements
s.resize(4); // size is now 4, but the other 6 elements are not destroyed
s.shrink_to_fit(); // size is 4, and the other 6 elements are destroyed
template<typename T , size_t MaxLength>
iterator rti::core::bounded_sequence< T, MaxLength >::insert ( iterator  pos,
const T &  value 
)
inline

Inserts a new element in a position specified by an iterator.

Exceptions
dds::core::PreconditionNotMetErrorif size() == MaxLength
template<typename T , size_t MaxLength>
iterator rti::core::bounded_sequence< T, MaxLength >::erase ( iterator  pos)
inline

Erases an element specified by an iterator.

template<typename T , size_t MaxLength>
void rti::core::bounded_sequence< T, MaxLength >::push_back ( const T &  value)
inline

Adds a new element at the end.

Exceptions
dds::core::PreconditionNotMetErrorif size() == MaxLength
template<typename T , size_t MaxLength>
void rti::core::bounded_sequence< T, MaxLength >::push_back ( T &&  value)
inline

Adds a new element at the end by moving it.

Exceptions
dds::core::PreconditionNotMetErrorif size() == MaxLength
template<typename T , size_t MaxLength>
void rti::core::bounded_sequence< T, MaxLength >::pop_back ( )
inline

Removes the last element.

The element removed is not destroyed. To destroy it, follow pop_back with a call to shrink_to_fit.

template<typename T , size_t MaxLength>
void rti::core::bounded_sequence< T, MaxLength >::resize ( size_type  count)
inline

Resizes the container to contain count elements.

If count < size(), the sequence is reduced to the first count elements, but elements are not destroyed.

If count > size(), the sequence is expanded as follows: if capacity() >= count, new elements are not constructed, since they already had been. If capacity() < count, the extra elements are default-constructed.

Exceptions
dds::core::PreconditionNotMetErrorif count > MaxLength
template<typename T , size_t MaxLength>
void rti::core::bounded_sequence< T, MaxLength >::resize ( size_type  count,
const T &  value 
)
inline

Resizes the container to contain count elements.

This overload specifies the value.

template<typename T , size_t MaxLength>
void rti::core::bounded_sequence< T, MaxLength >::swap ( bounded_sequence< T, MaxLength > &  other)
inline

Swap the contents of two sequences.


RTI Connext Modern C++ API Version 5.3.1 Copyright © Mon Feb 19 2018 Real-Time Innovations, Inc