29 template <
class T,
int NumExtAlloc = DEFAULTVEC_ALLOC >
101 void Expand(
const int64_t newsize);
116 virtual void Resize(
const int64_t newsize,
const T&
object);
127 virtual void Resize(
const int64_t newsize);
140 int64_t
ExpandSize(
const int64_t proposed)
const;
151 template<
class T,
int NumExtAlloc >
159 if (size <= NumExtAlloc) {
174 template<
class T,
int NumExtAlloc >
183 if (size <= NumExtAlloc) {
197 for (int64_t i = 0; i <
size; i++) {
202 template<
class T,
int NumExtAlloc>
210 if (size <= (int64_t) (
sizeof (
fExtAlloc) /
sizeof (T))) {
224 for (int64_t i = 0; i <
size; i++) {
229 template<
class T,
int NumExtAlloc>
238 if (size <= (int64_t) (
sizeof (
fExtAlloc) /
sizeof (T))) {
252 for (int64_t i = 0; i <
size; i++) {
253 this->
fStore[i] = copy[i];
257 template<
class T,
int NumExtAlloc>
260 int size = list.size();
261 std::cout <<
"init pzmanvec" << std::endl;
262 if (size <= (int64_t)(
sizeof(
fExtAlloc) /
sizeof(T))) {
277 auto it_end = list.end();
279 for (
auto it = list.begin(); it != it_end; it++, aux++)
284 template<
class T,
int NumExtAlloc >
299 if (nel <= NumExtAlloc) {
309 this->
fStore =
new T[ nel ];
314 for (int64_t i = 0; i < nel; i++) {
321 template<
class T,
int NumExtAlloc >
323 size_t size = list.size();
331 if (size <= NumExtAlloc) {
348 auto it_end = list.end();
350 for (
auto it = list.begin(); it != it_end; it++, aux++)
356 template<
class T,
int NumExtAlloc >
366 template<
class T,
int NumExtAlloc >
369 if (newsize <=
fNAlloc || newsize <= NumExtAlloc) {
372 T* newstore =
new T[ newsize ];
374 for (int64_t i = 0L; i < this->
fNElements; i++) {
375 newstore[i] = this->
fStore[i];
387 template<
class T,
int NumExtAlloc >
393 for (int64_t i = 0; i < this->
fNElements; i++)
410 for (int64_t i = 0; i < this->
fNElements; i++)
411 newstore[i] = this->
fStore[i];
425 template<
class T,
int NumExtAlloc >
429 PZError <<
"TManVec::Resize. Bad parameter newsize." << std::endl;
438 for (int64_t i = this->
fNElements; i < newsize; i++)
442 }
else if (newsize <= NumExtAlloc) {
451 for (; i < newsize; i++)
457 this->fNElements = newsize;
463 T* newstore =
new T[realsize];
466 newstore[i] = this->
fStore[i];
469 for (; i < newsize; i++)
470 newstore[i] =
object;
476 this->fNElements = newsize;
481 template<
class T,
int NumExtAlloc >
485 PZError <<
"TManVec::Resize. Bad parameter newsize." << std::endl;
496 }
else if (newsize <= NumExtAlloc) {
498 for (int64_t i = 0L; i < this->
fNElements; i++) {
511 T *newstore =
new T[realsize];
513 for (int64_t i = 0L; i < this->
fNElements; i++) {
514 newstore[i] = this->
fStore[i];
521 this->fNElements = newsize;
526 template<
class T,
int NumExtAlloc >
528 return ( proposed >
fNAlloc * 1.2 ? proposed :
529 static_cast<int64_t> (
fNAlloc * 1.2));
T fExtAlloc[NumExtAlloc]
Pointer to the externally allocated space.
TPZManVector(const int64_t size=0)
Creates a vector of a given size.
Implements a vector class which allows to use external storage provided by the user. Utility.
int fNAlloc
Number of elements allocated for this object.
Templated vector implementation.
This class implements a simple vector storage scheme for a templated class T. Utility.
int NAlloc() const
Returns number of elements allocated for this object.
void Expand(const int64_t newsize)
Expands the allocated storage to fit the newsize parameter.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
virtual ~TPZManVector()
Destructor.
int64_t size() const
Returns the number of elements of the vector.
void Shrink()
It reallocates storage to fit the necessary storage exactly.
int64_t ExpandSize(const int64_t proposed) const
Returns a suggested size for expanding the storage to fit the required storage.
T * fStore
Allocated storage for the vector object.
const int DEFAULTVEC_ALLOC
To allocate vector by default.
int64_t fNElements
Number of elements of the vector object.
int64_t NElements() const
Returns the number of elements of the vector.
TPZManVector< T, NumExtAlloc > & operator=(const TPZManVector< T, NumExtAlloc > ©)
Assignment operator.
#define PZError
Defines the output device to error messages and the DebugStop() function.