1 #ifndef CORE_VectorList_H
2 #define CORE_VectorList_H
11 template <
typename T,
class I>
19 std::vector<T> mValues;
67 mem+=mValues.capacity()*
sizeof(T);
87 return mValues.size();
100 if (i>=mValues.size()) {
103 "CORE_VectorList["+std::to_string(i)+
"] is out of bounds [0,"+std::to_string(mValues.size())+
"[ for reading");
113 if (i>=mValues.size()) {
116 "CORE_VectorList["+std::to_string(i)+
"] is out of bounds [0,"+std::to_string(mValues.size())+
"[ for writing");
131 return mValues.cbegin();
136 inline constexpr
auto cend()
const {
137 return mValues.cend();
143 return mValues.begin();
149 return mValues.end();
156 return mValues.rbegin();
162 return mValues.rend();
169 return mValues.crbegin();
174 inline constexpr
auto crend()
const {
175 return mValues.cend();
206 const Self* selfCpy=
dynamic_cast<const Self*
>(&cpy);
217 template<
typename Q,
class I1>
219 const Self *selfCpy=
dynamic_cast<const Self*
>(&cpy);
223 copy(cpy.size(),cpy.getValues());
231 inline void copy(
const std::initializer_list<T>& vs) {
238 inline void copy(std::initializer_list<T>&& vs) {
251 inline static void Copy(
const std::valarray<T>& X,std::vector<T>& R) {
252 Copy(X.size(),*X[0],R);
261 inline static void Copy(
const std::initializer_list<T>& X,std::vector<T>& R) {
269 inline static void Copy(std::initializer_list<T>&& X,std::vector<T>& R) {
281 inline static void Copy(
const std::vector<Q>& X,std::vector<T>& R) {
282 if (R.size()!=X.size()) R.resize(X.size());
297 inline static void Copy(
const std::vector<T>& X,std::vector<T>& R) {
309 inline static void Copy(
const tIndex& n,
const Q* X,std::vector<T>& R) {
310 if (R.size()!=n) R.resize(n);
355 return functions_type::getTypeName<T>();
365 template<
typename LambdaFct>
374 template<
typename LambdaFct>
387 template<
typename LambdaFct>
393 "CORE_VectorList::Transform(F,X,Y,R)",
394 "X ("+std::to_string(X.
getSize())+
") & Y ("+std::to_string(Y.
getSize())+
") have not same size");
410 std::sort(this->
begin(),this->
end(),std::less<tString>());
413 std::sort(this->
begin(),this->
end(),std::greater<tString>());
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:17
this class describes a list K -> T whre I is the implemented class
Definition: CORE_List.h:12
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
this class describes a list K -> T whre I is the implemented class
Definition: CORE_VectorList.h:12
tString getDataTypeName() const
get the type of data
Definition: CORE_VectorList.h:354
static void Copy(const std::vector< T > &X, std::vector< T > &R)
copy the array
Definition: CORE_VectorList.h:297
tIndex getSize() const
return the size of the container
Definition: CORE_VectorList.h:86
constexpr auto crend() const
return reverse end iterator for reading
Definition: CORE_VectorList.h:174
static void Copy(const tIndex &n, const Q *X, std::vector< T > &R)
copy the array
Definition: CORE_VectorList.h:309
static void Copy(const std::vector< Q > &X, std::vector< T > &R)
copy the array R=X
Definition: CORE_VectorList.h:281
static void Copy(std::initializer_list< T > &&X, std::vector< T > &R)
copy the array R=X
Definition: CORE_VectorList.h:269
void copy(std::initializer_list< T > &&vs)
initialize the array to the values of list
Definition: CORE_VectorList.h:238
const std::vector< T > & getValues() const
return the values of the list
Definition: CORE_VectorList.h:339
const T & operator[](const tIndex &i) const
get the i-th element for reading. Do not verify the bounds
Definition: CORE_VectorList.h:98
virtual tMemSize getMemorySize() const override
return the memory size of the class and the memory size of all its attributes/associations
Definition: CORE_VectorList.h:54
void directionalSort(const tUChar &order)
sort the element
Definition: CORE_VectorList.h:407
void setSize(const tIndex &n)
set the size of the container
Definition: CORE_VectorList.h:79
void copy(const Self &cpy)
copy the container
Definition: CORE_VectorList.h:205
void copy(const std::initializer_list< T > &vs)
initialize the array to the values of list
Definition: CORE_VectorList.h:231
auto rbegin()
return reverse begin iterator for writing
Definition: CORE_VectorList.h:155
auto begin()
return begin iterator for writing
Definition: CORE_VectorList.h:142
std::vector< T > & getValues()
return the values of the list
Definition: CORE_VectorList.h:332
constexpr auto crbegin() const
return reverse begin iterator for reading
Definition: CORE_VectorList.h:168
virtual ~CORE_VectorList()
destroy the instance of class
Definition: CORE_VectorList.h:38
T & operator[](const tIndex &i)
get the i-th element for writting. Do not verify the bounds
Definition: CORE_VectorList.h:111
CORE_VectorList()
build a list
Definition: CORE_VectorList.h:26
auto end()
return end iterator for writing
Definition: CORE_VectorList.h:148
constexpr auto cend() const
return end iterator for reading
Definition: CORE_VectorList.h:136
static void Copy(const std::initializer_list< T > &X, std::vector< T > &R)
copy the array R=X
Definition: CORE_VectorList.h:261
void transform(LambdaFct &&F)
transform the transform element with the lambda function Ti = F(Ti)
Definition: CORE_VectorList.h:366
static void Copy(const std::valarray< T > &X, std::vector< T > &R)
copy the array
Definition: CORE_VectorList.h:251
constexpr auto cbegin() const
return begin iterator for reading
Definition: CORE_VectorList.h:130
void copy(Self &&cpy)
copy the conatiner : mv is destroyed after this
Definition: CORE_VectorList.h:218
void transform(LambdaFct &&F, const Self &X)
transform the transform element with the lambda function Ti = F(Xi)
Definition: CORE_VectorList.h:375
virtual tMemSize getContentsMemorySize() const override
return the memory size of the included associations
Definition: CORE_VectorList.h:65
CORE_VectorList(const tIndex &n)
build a list of size n
Definition: CORE_VectorList.h:31
auto rend()
return reverse end iterator for writing
Definition: CORE_VectorList.h:161
void transform(LambdaFct &&F, const Self &X, const Self &Y)
transform the transform element with the lambda function Ti = F(Xi,Yi)
Definition: CORE_VectorList.h:388