ivl 679
ivl::array< T, OPTS > Class Template Reference

1-dimensional array of type T More...

#include <array.hpp>

Inherits ivl::array_common_base< C >, and vector< T >.

List of all members.

Public Types

typedef ptrdiff_t diff_type
 difference type of iterators
typedef size_t size_type
 parameter of resize, in each class of the hierarchy

Public Member Functions

void reshape (size_t len)
 Reshape is same as resize for 1-d arrays.
 ~array ()
 destructor
init member function
void init ()
 Init is behaves exactly like the constructor. See constructor reference.
void init (size_t count)
 Init is behaves exactly like the constructor. See constructor reference.
void init (int count)
 Init is behaves exactly like the constructor. See constructor reference.
void init (long int count)
 Init is behaves exactly like the constructor. See constructor reference.
void init (size_t count, const T &s)
 Init is behaves exactly like the constructor. See constructor reference.
void init (size_t count, const T *ptr)
 Init is behaves exactly like the constructor. See constructor reference.
template<class J >
void init (const internal::tuple_rvalue< J > &r)
 Init is behaves exactly like the constructor. See constructor reference.
void init (const array &a)
 Init is behaves exactly like the constructor. See constructor reference.
template<class J , class S >
void init (const array< J, S > &a, size_t n)
 Init is behaves exactly like the constructor. See constructor reference.
template<class J , class S >
void init (const array< J, S > &a)
 Init is behaves exactly like the constructor. See constructor reference.
template<class J , class S >
void init (size_t count, const array< J, S > &a)
 Init is behaves exactly like the constructor. See constructor reference.
Size functions
size_t length () const
 Get the length of the element sequence.
size_type size () const
 Get the size of the array. generic-class function.
size_t numel () const
 Get the length of the element sequence.
Element access

Access a unique element by specifying the position

std::vector< T >::const_reference operator[] (size_t offset) const
 Returns the const element found at position offset.
std::vector< T >::reference operator[] (size_t offset)
 Returns the element found at position offset.
Constructors
 array ()
 Default constructor.
 array (size_t count)
 Construnct by defining an initial number of elements.
 array (int count)
 Construnct by defining an initial number of elements.
 array (long int count)
 Construnct by defining an initial number of elements.
 array (size_t count, const T &s)
 Construnct by defining an initial number of elements and a default value.
 array (size_t count, const T *ptr)
 Construct by using a C array.
template<class S , int J>
 array (S(&arr)[J])
 Construct by using a C array.
template<class J >
 array (const internal::tuple_rvalue< J > &r)
 Construct array with rvalue.
 array (const array &a)
 Copy-constructor.
template<class J , class S >
 array (const array< J, S > &a, size_t n)
 construct from classes derived from array, using N elements
template<class J , class S >
 array (const array< J, S > &a)
 construct from an existing array of any type.
template<class J , class S >
 array (size_t count, const array< J, S > &a)
 Construct from array of the same type, using (shape, array)
Assignement Operators
template<class K >
derived_type & operator= (const K &k)
 Copy-Assign another array of identical type.
this_typeoperator= (const this_type &a)

Detailed Description

template<class T, class OPTS = data::mem<>>
class ivl::array< T, OPTS >

1-dimensional array of type T

This class defines an simple one-dimensional array.


Constructor & Destructor Documentation

template<class T, class OPTS = data::mem<>>
ivl::array< T, OPTS >::array ( size_t  count,
const T &  s 
) [inline]

Construnct by defining an initial number of elements and a default value.

Parameters:
countLength of the array
sDefault value for all elements
template<class T, class OPTS = data::mem<>>
ivl::array< T, OPTS >::array ( size_t  count,
const T *  ptr 
) [inline]

Construct by using a C array.

Parameters:
countLength of the array
ptrThe C array
template<class T, class OPTS = data::mem<>>
template<class S , int J>
ivl::array< T, OPTS >::array ( S(&)  arr[J]) [inline]

Construct by using a C array.

Parameters:
arrThe C array
template<class T, class OPTS = data::mem<>>
template<class J , class S >
ivl::array< T, OPTS >::array ( const array< J, S > &  a,
size_t  n 
) [inline]

construct from classes derived from array, using N elements

Developper's note: You cannot remove the defined constructor (above) even though it is a subset of this. This is because the copy constructor has a specific declaration, and should be declared to override the C++ default copy-constructor which is wrong and causes heap corruption.

template<class T, class OPTS = data::mem<>>
template<class J , class S >
ivl::array< T, OPTS >::array ( size_t  count,
const array< J, S > &  a 
) [inline]

Construct from array of the same type, using (shape, array)

This constructor has the same functionality as the (array, n) constructor, but fulfills a standard construction template that defines that all kinds of arrays (2d, nd etc) can be constructed with derived.size(), array<..> pair A difference is that this function can also accept zero length Also, if a is T or similar to the element type of the array this constructor fills in the array with count copies of the element a.


Member Function Documentation

template<class T, class OPTS = data::mem<>>
template<class K >
derived_type& ivl::array< T, OPTS >::operator= ( const K &  k) [inline]

Copy-Assign another array of identical type.

eg:

 ivl::array<int> a(10, 0);
 ivl::array<int> b;
 b = a; 

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations