27 #ifdef CH_USE_MEMORY_TRACKING 29 typedef std::pair<long int*, long int*> ppair;
30 typedef std::map<std::string, ppair > VectorList;
32 typedef std::list<int> lst;
33 typedef std::map<std::string, lst*> incr;
35 extern VectorList* vectorList_;
36 extern incr* vectorIncr_;
37 extern unsigned long long int ch_memcount;
74 #ifdef CH_USE_MEMORY_TRACKING 86 #ifdef CH_USE_MEMORY_TRACKING 87 increment(invec.
size());
93 :
v(std::move(a_invec.v))
104 #ifdef CH_USE_MEMORY_TRACKING 105 increment(invec.size());
116 #ifdef CH_USE_MEMORY_TRACKING 120 #ifdef CH_USE_MEMORY_TRACKING 129 v=std::move(a_invec.v);
138 #ifdef CH_USE_MEMORY_TRACKING 142 #ifdef CH_USE_MEMORY_TRACKING 155 v.assign(
size(),inval );
182 #ifdef CH_USE_MEMORY_TRACKING 209 Vector(
unsigned int isize,
const T& value) :
v(isize, value)
211 #ifdef CH_USE_MEMORY_TRACKING 297 #ifdef CH_USE_MEMORY_TRACKING 307 #ifdef CH_USE_MEMORY_TRACKING 311 v.push_back(std::move(in));
332 #ifdef CH_USE_MEMORY_TRACKING 333 increment(invec.
size());
335 for (
int ivec = 0; ivec < invec.
size(); ivec++)
338 v.push_back(invec[ivec]);
349 #ifdef CH_USE_MEMORY_TRACKING 350 if (isize >
size()) increment(isize-
size());
351 else decrement(
size()-isize);
353 unsigned int l=
size();
376 void resize(
unsigned int isize,
const T& value)
379 #ifdef CH_USE_MEMORY_TRACKING 380 if (isize >
size()) increment(isize-
size());
381 else decrement(
size()-isize);
384 v.resize(isize, value);
392 std::sort(
v.begin(),
v.end());
406 #ifdef CH_USE_MEMORY_TRACKING 408 static long int bytes;
409 static long int peak;
415 #ifdef CH_USE_MEMORY_TRACKING 417 void increment(
unsigned int i)
421 static unsigned int sizzle =
initFunc();
424 ch_memcount+=i*
sizeof(T);
426 if (bytes > peak) peak = bytes;
430 void decrement(
unsigned int i)
436 ch_memcount-=i*
sizeof(T);
446 #ifdef CH_USE_MEMORY_TRACKING 460 ostream& operator<<(ostream& os, const Vector<T>& vec)
462 for (
unsigned int i=0; i<vec.size(); i++) os<<vec[i]<<
" ";
466 #ifdef CH_USE_MEMORY_TRACKING 471 if (vectorList_ == NULL)
473 vectorList_ =
new VectorList;
474 vectorIncr_ =
new incr;
477 ppair tmp(&bytes, &peak);
478 vectorList_->operator[](
typeid(T).
name()) = tmp;
std::vector< T > & stdVector()
Returns std::vector under the hood.
Definition: Vector.H:396
#define CH_assert(cond)
Definition: CHArray.H:37
Vector< T > & operator=(const std::vector< T > &invec)
Definition: Vector.H:114
Vector(const Vector< T > &invec)
Definition: Vector.H:84
one dimensional dynamic array
Definition: Vector.H:53
size_t capacity() const
Definition: Vector.H:368
void swap(Vector< T > &other)
Definition: Vector.H:287
virtual ~Vector()
Definition: Vector.H:72
T & operator[](unsigned int n)
Definition: Vector.H:231
T & front()
Definition: Vector.H:263
void sort()
Definition: Vector.H:390
void append(const Vector< T > &invec)
Definition: Vector.H:330
void pop_back()
Definition: Vector.H:275
void resize(unsigned int isize)
Definition: Vector.H:346
void push_back(T &&in)
Definition: Vector.H:305
void push_back(const T &in)
Definition: Vector.H:295
void clear()
Definition: Vector.H:180
T & back()
Definition: Vector.H:269
const char * name(const FArrayBox &a_dummySpecializationArg)
Definition: CH_HDF5.H:907
const std::vector< T > & constStdVector() const
Definition: Vector.H:401
Vector< T > & assign(const T &inval)
assign a scalar to every element of the vector
Definition: Vector.H:153
Vector()
Definition: Vector.H:63
Vector(const std::vector< T > &invec)
Definition: Vector.H:102
size_t size() const
Definition: Vector.H:192
Vector(Vector< T > &&a_invec) noexcept
Definition: Vector.H:92
Vector(unsigned int isize, const T &value)
Definition: Vector.H:209
Vector< T > & operator=(Vector< T > &&a_invec)
Definition: Vector.H:127
void reserve(size_t isize)
Definition: Vector.H:362
Vector< T > & operator=(const Vector< T > &invec)
Definition: Vector.H:136
const T & back() const
Definition: Vector.H:281
void resize(unsigned int isize, const T &value)
Definition: Vector.H:376
Vector(unsigned int isize)
Definition: Vector.H:171
std::vector< T > v
Definition: Vector.H:443