//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
- MemArray<T>::MemArray(const MemArray<T>& other):_nb_of_elem(0),_nb_of_elem_alloc(0),_ownership(false),_dealloc(CPP_DEALLOC)
+ MemArray<T>::MemArray(const MemArray<T>& other):_nb_of_elem(0),_nb_of_elem_alloc(0),_ownership(false),_dealloc(0),_param_for_deallocator(0)
std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+other._nb_of_elem,pointer);
std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+other._nb_of_elem,pointer);
- useArray(pointer,true,CPP_DEALLOC,other._nb_of_elem);
+ useArray(pointer,true,C_DEALLOC,other._nb_of_elem);
}
}
template<class T>
void MemArray<T>::useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfElem)
{
}
}
template<class T>
void MemArray<T>::useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfElem)
{
template<class T>
void MemArray<T>::writeOnPlace(std::size_t id, T element0, const T *others, std::size_t sizeOfOthers)
{
template<class T>
void MemArray<T>::writeOnPlace(std::size_t id, T element0, const T *others, std::size_t sizeOfOthers)
{
std::copy(others,others+sizeOfOthers,pointer+id+1);
_nb_of_elem=std::max<std::size_t>(_nb_of_elem,id+sizeOfOthers+1);
}
std::copy(others,others+sizeOfOthers,pointer+id+1);
_nb_of_elem=std::max<std::size_t>(_nb_of_elem,id+sizeOfOthers+1);
}
template<class T>
template<class InputIterator>
void MemArray<T>::insertAtTheEnd(InputIterator first, InputIterator last)
template<class T>
template<class InputIterator>
void MemArray<T>::insertAtTheEnd(InputIterator first, InputIterator last)
template<class T>
void MemArray<T>::fillWithValue(const T& val)
{
T *pt=_pointer.getPointer();
std::fill(pt,pt+_nb_of_elem,val);
}
template<class T>
void MemArray<T>::fillWithValue(const T& val)
{
T *pt=_pointer.getPointer();
std::fill(pt,pt+_nb_of_elem,val);
}
throw INTERP_KERNEL::Exception("MemArray<T>::fromNoInterlace : number of components must be > 0 !");
const T *pt=_pointer.getConstPointer();
std::size_t nbOfTuples=_nb_of_elem/nbOfComp;
throw INTERP_KERNEL::Exception("MemArray<T>::fromNoInterlace : number of components must be > 0 !");
const T *pt=_pointer.getConstPointer();
std::size_t nbOfTuples=_nb_of_elem/nbOfComp;
T *w=ret;
for(std::size_t i=0;i<nbOfTuples;i++)
for(int j=0;j<nbOfComp;j++,w++)
*w=pt[j*nbOfTuples+i];
return ret;
}
T *w=ret;
for(std::size_t i=0;i<nbOfTuples;i++)
for(int j=0;j<nbOfComp;j++,w++)
*w=pt[j*nbOfTuples+i];
return ret;
}
throw INTERP_KERNEL::Exception("MemArray<T>::toNoInterlace : number of components must be > 0 !");
const T *pt=_pointer.getConstPointer();
std::size_t nbOfTuples=_nb_of_elem/nbOfComp;
throw INTERP_KERNEL::Exception("MemArray<T>::toNoInterlace : number of components must be > 0 !");
const T *pt=_pointer.getConstPointer();
std::size_t nbOfTuples=_nb_of_elem/nbOfComp;
T *w=ret;
for(int i=0;i<nbOfComp;i++)
for(std::size_t j=0;j<nbOfTuples;j++,w++)
T *w=ret;
for(int i=0;i<nbOfComp;i++)
for(std::size_t j=0;j<nbOfTuples;j++,w++)
std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min<std::size_t>(_nb_of_elem,newNbOfElements),pointer);
if(_ownership)
std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min<std::size_t>(_nb_of_elem,newNbOfElements),pointer);
if(_ownership)
_pointer.setInternal(pointer);
_nb_of_elem=std::min<std::size_t>(_nb_of_elem,newNbOfElements);
_nb_of_elem_alloc=newNbOfElements;
_ownership=true;
_pointer.setInternal(pointer);
_nb_of_elem=std::min<std::size_t>(_nb_of_elem,newNbOfElements);
_nb_of_elem_alloc=newNbOfElements;
_ownership=true;
std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min<std::size_t>(_nb_of_elem,newNbOfElements),pointer);
if(_ownership)
std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min<std::size_t>(_nb_of_elem,newNbOfElements),pointer);
if(_ownership)
_pointer.setInternal(pointer);
_nb_of_elem=newNbOfElements;
_nb_of_elem_alloc=newNbOfElements;
_ownership=true;
_pointer.setInternal(pointer);
_nb_of_elem=newNbOfElements;
_nb_of_elem_alloc=newNbOfElements;
_ownership=true;
- std::ostringstream stream;
- stream << "Invalid deallocation requested for pointer " << pt;
- throw INTERP_KERNEL::Exception(stream.str().c_str());
- }
+ throw INTERP_KERNEL::Exception("Invalid deallocation requested ! Unrecognized enum DeallocType !");
+ }
+ }
+
+ template<class T>
+ void MemArray<T>::DestroyPointer(T *pt, typename MemArray<T>::Deallocator dealloc, void *param)
+ {
+ if(dealloc)
+ dealloc(pt,param);