mln::util::array< T > Class Template Reference
[Utilities]

A dynamic array class. More...

#include <array.hh>

Inheritance diagram for mln::util::array< T >:

Inheritance graph

List of all members.

Public Types

typedef Function_v2v< void > category
typedef T element
 Element associated type.
typedef E exact_t
typedef array_bkd_iter< T > bkd_eiter
 Backward iterator associated type.
typedef fwd_eiter eiter
 Iterator associated type.
typedef array_fwd_iter< T > fwd_eiter
 Iterator types

Forward iterator associated type.

typedef std::vector< T >::reference mutable_result
typedef T result
 Returned value types.
typedef std::vector< T >
::const_reference 
ro_result

Public Member Functions

template<typename U>
array< T > & append (const array< U > &other)
 Add the elements of other at the end of this array.
array< T > & append (const T &elt)
 Add the element elt at the end of this array.
void clear ()
 Empty the array.
void fill (const T &value)
 Fill the whole array with value value.
std::vector< T > & hook_std_vector_ ()
 Hook to the mutable std::vector of elements.
bool is_empty () const
 Test if the array is empty.
std::size_t memory_size () const
 Return the size of this array in memory.
unsigned nelements () const
 Return the number of elements of the array.
mutable_result operator() (unsigned i)
 Return the i-th element of the array.
ro_result operator() (unsigned i) const
 Return the i-th element of the array.
mutable_result operator[] (unsigned i)
 Return the i-th element of the array.
ro_result operator[] (unsigned i) const
 Return the i-th element of the array.
void reserve (unsigned n)
 Reserve memory for n elements.
void resize (unsigned n, const T &value)
 Resize this array to n elements with value as value.
void resize (unsigned n)
 Resize this array to n elements.
unsigned size () const
 Return the number of elements of the array.
const std::vector< T > & std_vector () const
 Return the corresponding std::vector of elements.
 array (unsigned n, const T &value)
 Construct a new array, resize it to
elements and fill it with default_value.
 array (unsigned n)
 Construct a new array and resize it to
elements.
 array ()
 Constructors

Constructor without arguments.


Private Attributes

std::vector< T > v_


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 99 of file util/array.hh.


Member Typedef Documentation

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

Backward iterator associated type.

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

template<typename E>
typedef Function_v2v<void> mln::Function_v2v< E >::category [inherited]

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

Iterator associated type.

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

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

Element associated type.

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

template<typename E>
typedef E mln::Object< E >::exact_t [inherited]

Definition at line 172 of file object.hh.

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

Iterator types

Forward iterator associated type.

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

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

Reimplemented from mln::Function_v2v< E >.

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

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

Returned value types.

Related to the Function_v2v concept.

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

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

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


Constructor & Destructor Documentation

template<typename T>
mln::util::array< T >::array (  )  [inline]

Constructors

Constructor without arguments.

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

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

Construct a new array and resize it to
elements.

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

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

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

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


Member Function Documentation

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

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

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

References mln::util::array< T >::is_empty(), mln::util::array< T >::std_vector(), and mln::util::array< T >::v_.

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

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

Empty the array.

All elements contained in the array are destroyed.

Postcondition:
is_empty() == true

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

References mln::util::array< T >::is_empty(), and mln::util::array< T >::v_.

Referenced by mln::p_mutable_array_of< S >::clear(), and mln::io::plot::load().

template<typename T>
void mln::util::array< T >::fill ( const T &  value  )  [inline]

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

Hook to the mutable std::vector of elements.

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

References mln::util::array< T >::v_.

Referenced by mln::data::impl::generic::sort_offsets_decreasing(), and mln::data::impl::generic::sort_offsets_increasing().

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

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

Return the size of this array in memory.

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

References mln::util::array< T >::nelements().

Referenced by mln::p_mutable_array_of< S >::memory_size().

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

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

Return the i-th element of the array.

Precondition:
i < nelements()

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

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

Return the i-th element of the array.

Precondition:
i < nelements()

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

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

Return the i-th element of the array.

Precondition:
i < nelements()

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

References mln::util::array< T >::nelements(), and mln::util::array< T >::v_.

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

Return the i-th element of the array.

Precondition:
i < nelements()

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

References mln::util::array< T >::nelements(), and mln::util::array< T >::v_.

template<typename T>
void mln::util::array< T >::reserve ( unsigned  n  )  [inline]

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

Resize this array to n elements with value as value.

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

References mln::util::array< T >::v_.

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

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

Return the number of elements of the array.

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

See also:
nelements

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

References mln::util::array< T >::nelements().

Referenced by mln::value::lut_vec< S, T >::lut_vec(), and mln::labeled_image_base< I, E >::update_data().

template<typename T>
const std::vector< T > & mln::util::array< T >::std_vector (  )  const [inline]

Return the corresponding std::vector of elements.

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

References mln::util::array< T >::v_.

Referenced by mln::util::array< T >::append(), mln::value::lut_vec< S, T >::lut_vec(), and mln::util::operator==().


Member Data Documentation

template<typename T>
std::vector<T> mln::util::array< T >::v_ [private]


Generated on Sun Apr 25 02:07:22 2010 for Milena (Olena) by  doxygen 1.5.6