ivl 679
|
1-dimensional array of type T More...
#include <little_class.hpp>
Inherits array_common_base< array< T, data::stack< N, USE_REALLOC, USE_PREALLOC, DERIVED_INFO > > >.
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 | init (size_t len) |
Init is same as resize for 1-d arrays. | |
void | reshape (size_t len) |
Reshape is same as resize for 1-d arrays. | |
~array () | |
destructor | |
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 | |
const T & | operator[] (size_t offset) const |
Returns the const element found at position offset. | |
T & | 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 J > | |
array (const internal::tuple_rvalue< J > &r) | |
Construct array with rvalue. | |
array (const this_type &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 | |
this_type & | operator= (const this_type &a) |
1-dimensional array of type T
This class defines an simple one-dimensional array. little array has the following properties: + very fast for small data that are <= N in size + economic in memory allocation. does free extra memory on resize in chunks of 64K elements, for larger sizes. -/+ optimized for small data. + can hold any size data, even > 4GB for a 64-bit system.
Note: some (few) element classes will be completely invalid with USE_REALLOC. Those are classes that depend on their own pointer location, e.g. have references on their own data. array<little> is one of those classes itself!
array< T, data::stack< N, USE_REALLOC, USE_PREALLOC, DERIVED_INFO > >::array | ( | size_t | count, |
const T & | s | ||
) | [inline] |
Construnct by defining an initial number of elements and a default value.
count | Length of the array |
s | Default value for all elements |
array< T, data::stack< N, USE_REALLOC, USE_PREALLOC, DERIVED_INFO > >::array | ( | size_t | count, |
const T * | ptr | ||
) | [inline] |
Construct by using a C array.
count | Length of the array |
ptr | The C array |
array< T, data::stack< N, USE_REALLOC, USE_PREALLOC, DERIVED_INFO > >::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 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.
array< T, data::stack< N, USE_REALLOC, USE_PREALLOC, DERIVED_INFO > >::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