FIMS  v0.8.0
Loading...
Searching...
No Matches
fims::Vector< Type > Class Template Reference

#include <fims_vector.hpp>

Public Types

typedef std::vector< Type >::value_type value_type
 
typedef std::vector< Type >::allocator_type allocator_type
 
typedef std::vector< Type >::size_type size_type
 
typedef std::vector< Type >::difference_type difference_type
 
typedef std::vector< Type >::reference reference
 
typedef std::vector< Type >::const_reference const_reference
 
typedef std::vector< Type >::pointer pointer
 
typedef std::vector< Type >::const_pointer const_pointer
 
typedef std::vector< Type >::iterator iterator
 
typedef std::vector< Type >::const_iterator const_iterator
 
typedef std::vector< Type >::reverse_iterator reverse_iterator
 
typedef std::vector< Type >::const_reverse_iterator const_reverse_iterator
 

Public Member Functions

 Vector ()
 
 Vector (size_t size, const Type &value=Type())
 Constructs a Vector of length "size" and sets the elements with the value from input "value".
 
 Vector (const Vector< Type > &other)
 Copy constructor.
 
Vectoroperator= (const Vector &other)
 Assignment operator for fims::Vector.
 
 Vector (const std::vector< Type > &other)
 Initialization constructor from std::vector<Type> type.
 
 Vector (std::initializer_list< Type > init)
 Initialization constructor from std::initializer_list<Type> type.
 
Typeoperator[] (size_t pos)
 Returns a reference to the element at specified location pos. No bounds checking is performed.
 
const Typeoperator[] (size_t n) const
 Returns a constant reference to the element at specified location pos. No bounds checking is performed.
 
Typeat (size_t n)
 Returns a reference to the element at specified location pos. Bounds checking is performed.
 
const Typeat (size_t n) const
 Returns a constant reference to the element at specified location pos. Bounds checking is performed.
 
Typeget_force_scalar (size_t pos)
 If this vector is size 1 and pos is greater than zero, the first index is returned. If this vector has size greater than 1 and pos is greater than size, a invalid_argument exception is thrown. Otherwise, the value at index pos is returned.
 
reference front ()
 Returns a reference to the first element in the container.
 
const_reference front () const
 Returns a constant reference to the first element in the container.
 
reference back ()
 Returns a reference to the last element in the container.
 
const_reference back () const
 Returns a constant reference to the last element in the container.
 
pointer data ()
 Returns a pointer to the underlying data array.
 
const_pointer data () const
 Returns a constant pointer to the underlying data array.
 
iterator begin ()
 Returns an iterator to the first element of the vector.
 
iterator end ()
 Returns an iterator to the element following the last element of the vector.
 
reverse_iterator rbegin ()
 Returns a reverse iterator to the first element of the reversed vector. It corresponds to the last element of the non-reversed vector.
 
reverse_iterator rend ()
 Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector.
 
const_reverse_iterator rbegin () const
 Returns a constant reverse iterator to the first element of the reversed vector. It corresponds to the last element of the non-reversed vector.
 
const_reverse_iterator rend () const
 Returns a constant reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector.
 
bool empty ()
 Checks whether the container is empty.
 
size_type size () const
 Returns the number of elements.
 
size_type max_size () const
 Returns the maximum possible number of elements.
 
void reserve (size_type cap)
 Reserves storage.
 
size_type capacity ()
 Returns the number of elements that can be held in currently allocated storage.
 
void shrink_to_fit ()
 Reduces memory usage by freeing unused memory.
 
void clear ()
 Clears the contents.
 
iterator insert (const_iterator pos, const Type &value)
 Inserts value before pos.
 
iterator insert (const_iterator pos, size_type count, const Type &value)
 Inserts count copies of the value before pos.
 
template<class InputIt >
iterator insert (const_iterator pos, InputIt first, InputIt last)
 Inserts elements from range [first, last) before pos.
 
iterator insert (const_iterator pos, std::initializer_list< Type > ilist)
 Inserts elements from initializer list ilist before pos.
 
template<class... Args>
iterator emplace (const_iterator pos, Args &&...args)
 Constructs element in-place.
 
iterator erase (iterator pos)
 Removes the element at pos.
 
iterator erase (iterator first, iterator last)
 Removes the elements in the range [first, last).
 
void push_back (const Type &&value)
 Adds an element to the end.
 
template<class... Args>
void emplace_back (Args &&...args)
 Constructs an element in-place at the end.
 
void pop_back ()
 Removes the last element.
 
void resize (size_t s)
 Changes the number of elements stored.
 
void swap (Vector &other)
 Swaps the contents.
 
 operator std::vector< Type > ()
 Converts fims::Vector<Type> to std::vector<Type>
 
std::vector< Typeto_std () const
 Convert fims::Vector to std::vector.
 
std::vector< Typeto_tmb () const
 Convert fims::Vector to TMB vector type.
 
std::string get_tag () const
 Gets the tag for the vector. A tag can represent anything and is not used internally by FIMS.
 
void set_tag (const std::string &tag)
 Sets the tag for the vector. A tag can be set to any string value and is not used internally by FIMS.
 

Friends

template<typename T >
bool operator== (const fims::Vector< T > &lhs, const fims::Vector< T > &rhs)
 friend comparison operator. Allows the operator to see private members of fims::Vector<Type>.
 

Detailed Description

template<typename Type>
class fims::Vector< Type >

Wrapper class for std::vector types. If this file is compiled with -DTMB_MODEL, conversion operators are defined for TMB vector types.

All std::vector functions are copied over from the std library. While some of these may not be called explicitly in FIMS, they may be required to run other std library functions.

Member Typedef Documentation

◆ allocator_type

template<typename Type >
typedef std::vector<Type>::allocator_type fims::Vector< Type >::allocator_type

Allocator for type Type>

◆ const_iterator

template<typename Type >
typedef std::vector<Type>::const_iterator fims::Vector< Type >::const_iterator

Constant iterator>

◆ const_pointer

template<typename Type >
typedef std::vector<Type>::const_pointer fims::Vector< Type >::const_pointer

Constant pointer type const Type*>

◆ const_reference

template<typename Type >
typedef std::vector<Type>::const_reference fims::Vector< Type >::const_reference

Constant reference type const &Type>

◆ const_reverse_iterator

template<typename Type >
typedef std::vector<Type>::const_reverse_iterator fims::Vector< Type >::const_reverse_iterator

Constant reverse iterator>

◆ difference_type

template<typename Type >
typedef std::vector<Type>::difference_type fims::Vector< Type >::difference_type

Difference type>

◆ iterator

template<typename Type >
typedef std::vector<Type>::iterator fims::Vector< Type >::iterator

Iterator>

◆ pointer

template<typename Type >
typedef std::vector<Type>::pointer fims::Vector< Type >::pointer

Pointer type Type*>

◆ reference

template<typename Type >
typedef std::vector<Type>::reference fims::Vector< Type >::reference

Reference type &Type>

◆ reverse_iterator

template<typename Type >
typedef std::vector<Type>::reverse_iterator fims::Vector< Type >::reverse_iterator

Reverse iterator>

◆ size_type

template<typename Type >
typedef std::vector<Type>::size_type fims::Vector< Type >::size_type

Size type>

◆ value_type

template<typename Type >
typedef std::vector<Type>::value_type fims::Vector< Type >::value_type

Member type Type>

Constructor & Destructor Documentation

◆ Vector()

template<typename Type >
fims::Vector< Type >::Vector ( )
inline

Default constructor.

Member Function Documentation

◆ back()

template<typename Type >
const_reference fims::Vector< Type >::back ( ) const
inline

Returns a constant reference to the last element in the container.

␁*

◆ get_force_scalar()

template<typename Type >
Type & fims::Vector< Type >::get_force_scalar ( size_t  pos)
inline

If this vector is size 1 and pos is greater than zero, the first index is returned. If this vector has size greater than 1 and pos is greater than size, a invalid_argument exception is thrown. Otherwise, the value at index pos is returned.

Parameters
pos
Returns
a constant reference to the element at specified location

◆ get_tag()

template<typename Type >
std::string fims::Vector< Type >::get_tag ( ) const
inline

Gets the tag for the vector. A tag can represent anything and is not used internally by FIMS.

Returns
The tag.

◆ operator std::vector< Type >()

template<typename Type >
fims::Vector< Type >::operator std::vector< Type > ( )
inline

Converts fims::Vector<Type> to std::vector<Type>

Conversion operators

◆ operator=()

template<typename Type >
Vector & fims::Vector< Type >::operator= ( const Vector< Type > &  other)
inline

Assignment operator for fims::Vector.

Assigns the contents of another fims::Vector to this vector. Cleans up existing contents and performs a deep copy.

Parameters
otherThe vector to assign from.
Returns
Reference to this vector.

◆ operator[]()

template<typename Type >
Type & fims::Vector< Type >::operator[] ( size_t  pos)
inline

Returns a reference to the element at specified location pos. No bounds checking is performed.

The following are std::vector functions copied over from the standard library. While some of these may not be called explicitly in FIMS, they may be required to run other std library functions.

◆ to_std()

template<typename Type >
std::vector< Type > fims::Vector< Type >::to_std ( ) const
inline

Convert fims::Vector to std::vector.

Returns a standard vector containing the same elements as the fims::Vector.

Returns
std::vector<Type> with the same elements.

◆ to_tmb()

template<typename Type >
std::vector< Type > fims::Vector< Type >::to_tmb ( ) const
inline

Convert fims::Vector to TMB vector type.

Returns a TMB-compatible vector containing the same elements as the fims::Vector. Only available if compiled with TMB_MODEL.

Returns
TMB vector type with the same elements.

The documentation for this class was generated from the following file: