ztsdb
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
arr::Array< T, O > Struct Template Reference

#include <array.hpp>

Public Types

typedef T value_type
 
typedef O comparator
 
typedef Vector< T, O > vector_type
 

Public Member Functions

template<typename U >
 Array (seq_to_t, T t1, T t2, U by, std::unique_ptr< AllocFactory > &&allocf_p=std::make_unique< MemAllocFactory >())
 construct a sequence in place, from 't1' to 't2'.
 
template<typename U >
 Array (seq_n_t, T t1, U by, idx_type n, std::unique_ptr< AllocFactory > &&allocf_p=std::make_unique< MemAllocFactory >())
 construct a sequence in place, from 't1', with 'n' elements.
 
template<typename INIT_TYPE_TAG >
 Array (INIT_TYPE_TAG init, const Vector< idx_type > dim_p, const vector< Vector< zstring >> names_p=vector< Vector< zstring >>(), std::unique_ptr< AllocFactory > &&allocf_p=std::make_unique< MemAllocFactory >())
 
 Array (std::unique_ptr< AllocFactory > &&allocf_p)
 
 Array (const Vector< idx_type > dim_p, const Array< T > &v_p, const vector< Vector< zstring >> names_p=vector< Vector< zstring >>(), std::unique_ptr< AllocFactory > &&allocf_p=std::make_unique< MemAllocFactory >())
 
 Array (const Vector< idx_type > dim_p, const Vector< T, O > &v_p, const vector< Vector< zstring >> names_p=vector< Vector< zstring >>(), std::unique_ptr< AllocFactory > &&allocf_p=std::make_unique< MemAllocFactory >())
 
 Array (const Vector< idx_type > dim_p, const vector< unique_ptr< Vector< T, O >>> &v_p, const vector< unique_ptr< Dname >> &names_p, std::unique_ptr< AllocFactory > &&allocf_p=std::make_unique< MemAllocFactory >())
 
 Array (const Array &u, std::unique_ptr< AllocFactory > &&allocf_p=std::make_unique< MemAllocFactory >())
 
template<typename U , typename OU = std::less<U>>
 Array (convert_cons_t, const Array< U, OU > &u, std::unique_ptr< AllocFactory > &&allocf_p=std::make_unique< MemAllocFactory >())
 Convert to another array type.
 
 Array (Array &&u)
 
template<typename U , class G >
 Array (const Array< U > &u, G g, bool abba, std::unique_ptr< AllocFactory > &&allocf_p=std::make_unique< MemAllocFactory >())
 
 Array (Vector< T, O > &&vv)
 
Arrayoperator= (Array u)
 
Arrayswap (Array &u)
 
bool operator== (const Array< T > &u) const
 
T & operator[] (idx_type i)
 
const T & operator[] (idx_type i) const
 
size_t getBufferSize () const
 
size_t to_buffer (char *buf) const
 
template<typename INDEX >
Array< T > operator() (const INDEX &i) const
 Complex subsetting. More...
 
template<typename INDEX >
Array operator() (const vector< INDEX > &i, bool drop=true, idx_type dropfirst=0) const
 
template<typename INDEX , typename U >
Arrayoperator() (const vector< INDEX > &i, const Array< U > &u)
 subassign an array.
 
template<typename INDEX , typename U >
Arrayoperator() (const vector< INDEX > &i, U u)
 subassign a scalar.
 
operator[] (const vector< idx_type > &i) const
 
Array subsetRows (idx_type n, idx_type from=0, bool addrownums=false) const
 Subset the specified row range:
 
bool hasNames () const
 
bool hasNames (idx_type d) const
 
const DnamegetNames (idx_type d) const
 
const Vector< zstring > & getNamesVector (idx_type d) const
 
bool isVector () const
 
bool isScalar () const
 
bool isOrdered () const
 
bool isOrdered (idx_type i) const
 
const AllocFactorygetAllocFactory () const
 
Arrayaddprefix (const string &prefix, idx_type d)
 
idx_type size () const
 Get the total number of elements in the array.
 
idx_type ncols () const
 
idx_type nrows () const
 
const Vector< T, O > & getcol (idx_type i) const
 
Vector< T, O > & getcol (idx_type i)
 
const Dnamegetnames (idx_type d) const
 Get the vector of names in dimention d.
 
const Vector< idx_type > & getdim () const
 
const idx_type getdim (idx_type d) const
 
fsys::path getAllocfDirname () const
 
bool isPersistent () const
 
void msync (bool async) const
 
template<typename U >
Arrayconcat (const Array< U > &u, const string &prefix="")
 
template<typename U >
Arrayconcat (const U &u, const string &name="")
 
template<typename U >
Arrayabind (const Array< U > &u, idx_type d, const string &prefix="")
 
template<typename U >
Arrayrbind (const Array< U > &u)
 
template<typename U >
Arraycbind (const Array< U > &u)
 
Arrayappend (const char *buf, size_t buflen, size_t &offset)
 
ArrayappendVector (const char *buf, size_t buflen)
 
Arrayresize (idx_type d, idx_type sz, idx_type from=0)
 
template<class F >
Arrayapplyf (F f)
 Apply a function on every element of an array.
 
template<typename F , typename ... U>
Arrayapply (const U &... u)
 
template<class F , typename U >
Arrayapply_scalar_post (U u)
 
template<typename F , typename U >
Arrayapply (const U &u)
 
template<class F , typename U , typename A >
Arrayapply_attrib (const Array< U > &u, const A &a)
 
template<class F , typename U , typename A >
Arrayapply_attrib_scalar_post (U u, const A &a)
 
template<typename AO = O>
Arraysort ()
 
template<typename AO = O>
Arraysort (idx_type col)
 
template<class UnaryFunction >
UnaryFunction for_each (UnaryFunction f) const
 
template<typename U , typename AO = O>
Array< U > sort_idx (idx_type base) const
 

Static Public Member Functions

static bool checkdims (const Vector< idx_type > &v, const Vector< idx_type > &u, idx_type i)
 

Public Attributes

Vector< idx_type > dim
 
vector< unique_ptr< Vector< T, O > > > v
 
vector< unique_ptr< Dname > > names
 v is a set of cols, v[0], v[1] are the cols
 
std::unique_ptr< AllocFactoryallocf
 

Detailed Description

template<typename T, typename O = std::less<T>>
struct arr::Array< T, O >

Defines an array type. It is multidimensional, the storage is one vector per column.

Constructor & Destructor Documentation

◆ Array() [1/4]

template<typename T , typename O = std::less<T>>
template<typename INIT_TYPE_TAG >
arr::Array< T, O >::Array ( INIT_TYPE_TAG  init,
const Vector< idx_type >  dim_p,
const vector< Vector< zstring >>  names_p = vector<Vector<zstring>>(),
std::unique_ptr< AllocFactory > &&  allocf_p = std::make_unique<MemAllocFactory>() 
)
inline

construct array of given dimension, without initializing content. this is bad as the Array is left in an incoherent state LLL

◆ Array() [2/4]

template<typename T , typename O = std::less<T>>
arr::Array< T, O >::Array ( std::unique_ptr< AllocFactory > &&  allocf_p)
inline

Construct an array from file. Note that the data must have been tested to determine typename 'T'.

◆ Array() [3/4]

template<typename T , typename O = std::less<T>>
arr::Array< T, O >::Array ( const Vector< idx_type >  dim_p,
const Vector< T, O > &  v_p,
const vector< Vector< zstring >>  names_p = vector<Vector<zstring>>(),
std::unique_ptr< AllocFactory > &&  allocf_p = std::make_unique<MemAllocFactory>() 
)
inline

Main constructor with, as parameters, a vector of values, a dimension vector, column names and potentially a directory name. If the directory name is specified, the array will be memory mapped.

◆ Array() [4/4]

template<typename T , typename O = std::less<T>>
arr::Array< T, O >::Array ( const Vector< idx_type >  dim_p,
const vector< unique_ptr< Vector< T, O >>> &  v_p,
const vector< unique_ptr< Dname >> &  names_p,
std::unique_ptr< AllocFactory > &&  allocf_p = std::make_unique<MemAllocFactory>() 
)
inline

nearly a copy constructor! need to figure out which allocator to use here LLL

Member Function Documentation

◆ abind()

template<typename T , typename O = std::less<T>>
template<typename U >
Array& arr::Array< T, O >::abind ( const Array< U > &  u,
idx_type  d,
const string &  prefix = "" 
)
inline

bind arrays 't' and 'u' in an arbitrary dimension 'd'. bind rules: arrays with one of more 0 in a dimension: b 0x1, 0x1, d1 = 0 x 2; note that names exist, but no data b 0x0, 0x1, d1 = 0 x 1;
if there's just one 0 in any dimension, then bind with a non-empty vector is equivalent (for data) to a copy

◆ append()

template<typename T , typename O = std::less<T>>
Array& arr::Array< T, O >::append ( const char *  buf,
size_t  buflen,
size_t &  offset 
)
inline

LLL, yes, we do!!!

◆ appendVector()

template<typename T , typename O = std::less<T>>
Array& arr::Array< T, O >::appendVector ( const char *  buf,
size_t  buflen 
)
inline

LLL, yes, we do!!!

◆ apply()

template<typename T , typename O = std::less<T>>
template<typename F , typename ... U>
Array& arr::Array< T, O >::apply ( const U &...  u)
inline

Apply functor F to any number of arguments. Each argument must have a 'getcol' function that returns an instance of a class that is subsettable. In addition the type 'U' must have a 'vector_type' typedef.

◆ checkdims()

template<typename T , typename O = std::less<T>>
static bool arr::Array< T, O >::checkdims ( const Vector< idx_type > &  v,
const Vector< idx_type > &  u,
idx_type  i 
)
inlinestatic

Checks if dimensions of vectors 'v' and 'u' are compatible for a bind in dimension 'i'.

◆ concat()

template<typename T , typename O = std::less<T>>
template<typename U >
Array& arr::Array< T, O >::concat ( const U &  u,
const string &  name = "" 
)
inline

Concatenate (push_back) one scalar element at the end of a Array vector. The Array must be a vector.

◆ getBufferSize()

template<typename T , typename O = std::less<T>>
size_t arr::Array< T, O >::getBufferSize ( ) const
inline

Allocate and serialize the array to a buffer. Note that only the data gets copied out - column names are ignored.

◆ operator()()

template<typename T , typename O = std::less<T>>
template<typename INDEX >
Array<T> arr::Array< T, O >::operator() ( const INDEX &  i) const
inline

Complex subsetting.

Subset a vector or a multidimentional array as a vector with one index. This function does not handle dimnames. When the dimnames are desired for a vector, the operator that takes a vector of index will do the correct job. For multidimential array dimnames cannot be preserved.

◆ operator==()

template<typename T , typename O = std::less<T>>
bool arr::Array< T, O >::operator== ( const Array< T > &  u) const
inline

equality operator. We require that both the content and the names be equal.


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