$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mln::util::array< T > Class Template Reference

#include <mln/util/array.hh>

Public Member Functions

array< T > & append (const T &elt)
template<typename U >
array< T > & append (const array< U > &other)
void clear ()
void fill (const T &value)
std::vector< T > & hook_std_vector_ ()
bool is_empty () const
ro_result last () const
mutable_result last ()
std::size_t memory_size () const
unsigned nelements () const
ro_result operator() (unsigned i) const
mutable_result operator() (unsigned i)
ro_result operator[] (unsigned i) const
mutable_result operator[] (unsigned i)
void reserve (unsigned n)
void resize (unsigned n)
void resize (unsigned n, const T &value)
unsigned size () const
const std::vector< T > & std_vector () const
Constructors
 array ()
 array (unsigned n)
 array (unsigned n, const T &value)

Public Types

typedef T element
Returned value types.

Related to the Function_v2v concept.

typedef T result
typedef std::vector< T >
::const_reference 
ro_result
typedef std::vector< T >::reference mutable_result
Iterator types
typedef array_fwd_iter< Tfwd_eiter
typedef array_bkd_iter< Tbkd_eiter
typedef fwd_eiter eiter

Related Functions

(Note that these are not member functions.)

template<typename T >
std::ostream & operator<< (std::ostream &ostr, const array< T > &a)
template<typename T >
bool operator== (const array< T > &lhs, const array< T > &rhs)

Detailed Description

template<typename T>
class mln::util::array< T >

A dynamic array class.

Elements are stored by copy. Implementation is lazy.

The parameter T is the element type, which shall not be const-qualified.

Definition at line 80 of file util/array.hh.

Constructor & Destructor Documentation

template<typename T>
mln::util::array< T >::array ( )

Constructor without argument.

template<typename T>
mln::util::array< T >::array ( unsigned  n)

Construct a new array and resize it to
elements.

template<typename T>
mln::util::array< T >::array ( unsigned  n,
const T value 
)

Construct a new array, resize it to
elements and fill it with default_value.

Member Function Documentation

template<typename T>
array<T>& mln::util::array< T >::append ( const T elt)

Add the element elt at the end of this array.

template<typename T>
template<typename U >
array<T>& mln::util::array< T >::append ( const array< U > &  other)

Add the elements of other at the end of this array.

template<typename T>
void mln::util::array< T >::clear ( )

Empty the array.

All elements contained in the array are destroyed.

Postcondition
is_empty() == true
template<typename T>
void mln::util::array< T >::fill ( const T value)

Fill the whole array with value value.

template<typename T>
std::vector<T>& mln::util::array< T >::hook_std_vector_ ( )

Hook to the mutable std::vector of elements.

template<typename T>
bool mln::util::array< T >::is_empty ( ) const

Test if the array is empty.

template<typename T>
ro_result mln::util::array< T >::last ( ) const

Return the last element.

template<typename T>
mutable_result mln::util::array< T >::last ( )

Return the last element.

template<typename T>
std::size_t mln::util::array< T >::memory_size ( ) const

Return the size of this array in memory.

template<typename T>
unsigned mln::util::array< T >::nelements ( ) const

Return the number of elements of the array.

template<typename T>
ro_result mln::util::array< T >::operator() ( unsigned  i) const

Return the i-th element of the array.

Precondition
i < nelements()
template<typename T>
mutable_result mln::util::array< T >::operator() ( unsigned  i)

Return the i-th element of the array.

Precondition
i < nelements()
template<typename T>
ro_result mln::util::array< T >::operator[] ( unsigned  i) const

Return the i-th element of the array.

Precondition
i < nelements()
template<typename T>
mutable_result mln::util::array< T >::operator[] ( unsigned  i)

Return the i-th element of the array.

Precondition
i < nelements()
template<typename T>
void mln::util::array< T >::reserve ( unsigned  n)

Reserve memory for n elements.

template<typename T>
void mln::util::array< T >::resize ( unsigned  n)

Resize this array to n elements.

template<typename T>
void mln::util::array< T >::resize ( unsigned  n,
const T value 
)

Resize this array to n elements with value as value.

template<typename T>
unsigned mln::util::array< T >::size ( ) const

Return the number of elements of the array.

Added for compatibility with fun::i2v::array.

See Also
nelements
template<typename T>
const std::vector<T>& mln::util::array< T >::std_vector ( ) const

Return the corresponding std::vector of elements.

Friends And Related Function Documentation

template<typename T >
std::ostream & operator<< ( std::ostream &  ostr,
const array< T > &  a 
)
related

Operator<<.

template<typename T >
bool operator== ( const array< T > &  lhs,
const array< T > &  rhs 
)
related

Operator==.

Member Typedef Documentation

template<typename T>
typedef array_bkd_iter<T> mln::util::array< T >::bkd_eiter

Backward iterator associated type.

Definition at line 109 of file util/array.hh.

template<typename T>
typedef fwd_eiter mln::util::array< T >::eiter

Iterator associated type.

Definition at line 112 of file util/array.hh.

template<typename T>
typedef T mln::util::array< T >::element

Element associated type.

Definition at line 88 of file util/array.hh.

template<typename T>
typedef array_fwd_iter<T> mln::util::array< T >::fwd_eiter

Forward iterator associated type.

Definition at line 106 of file util/array.hh.

template<typename T>
typedef std::vector<T>::reference mln::util::array< T >::mutable_result

Definition at line 97 of file util/array.hh.

template<typename T>
typedef T mln::util::array< T >::result

Definition at line 95 of file util/array.hh.

template<typename T>
typedef std::vector<T>::const_reference mln::util::array< T >::ro_result

Definition at line 96 of file util/array.hh.