// Copyright (C) 2010, Guy Barrand. All rights reserved. // See the file tools.license for terms. #ifndef tools_array #define tools_array #include #include namespace tools { // array handles an hyperparallelepiped of cells of class T. template class array { public: static const std::string& s_class() { static const std::string s_v("tools::array"); return s_v; } public: typedef typename std::vector uints_t; public: array() { } array(const uints_t& a_orders) { configure(a_orders); } array(unsigned int a_dimension,unsigned int a_order) { // A hypercube of dimension "a_dimension" and size "a_order". uints_t _orders(a_dimension); for(unsigned int index=0;index& vector() const { return m_vector;} std::vector& vector() { return m_vector;} bool fill(const std::vector& a_values) { size_t dsize = a_values.size(); size_t di = 0; unsigned int index = 0; for(auto it=m_vector.begin();it!=m_vector.end();++it,index++) { if(di>=dsize) return false; //a_values exhausted too early *it = a_values[di]; di++; } return true; } public: static T zero() { return T(); } protected: uints_t m_orders; uints_t m_offsets; std::vector m_vector; uints_t m_is; }; } #endif