class MEDCouplingPointer
{
public:
- MEDCOUPLING_EXPORT MEDCouplingPointer():_internal(0),_external(0) { }
- MEDCOUPLING_EXPORT void null() { _internal=0; _external=0; }
- MEDCOUPLING_EXPORT bool isNull() const { return _internal==0 && _external==0; }
- MEDCOUPLING_EXPORT void setInternal(T *pointer);
- MEDCOUPLING_EXPORT void setExternal(const T *pointer);
- MEDCOUPLING_EXPORT const T *getConstPointer() const { if(_internal) return _internal; else return _external; }
- MEDCOUPLING_EXPORT const T *getConstPointerLoc(std::size_t offset) const { if(_internal) return _internal+offset; else return _external+offset; }
- MEDCOUPLING_EXPORT T *getPointer() { if(_internal) return _internal; if(_external) throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); else return 0; }
+ MEDCOUPLING_EXPORT MEDCouplingPointer():_internal(0),_external(0) { }
+ MEDCOUPLING_EXPORT void null() { _internal=0; _external=0; }
+ MEDCOUPLING_EXPORT bool isNull() const { return _internal==0 && _external==0; }
+ MEDCOUPLING_EXPORT void setInternal(T *pointer);
+ MEDCOUPLING_EXPORT void setExternal(const T *pointer);
+ MEDCOUPLING_EXPORT const T *getConstPointer() const { if(_internal) return _internal; else return _external; }
+ MEDCOUPLING_EXPORT const T *getConstPointerLoc(std::size_t offset) const { if(_internal) return _internal+offset; else return _external+offset; }
+ MEDCOUPLING_EXPORT T *getPointer() { if(_internal) return _internal; if(_external) throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); else return 0; }
private:
T *_internal;
const T *_external;
typedef void (*Deallocator)(void *,void *);
public:
MEDCOUPLING_EXPORT MemArray():_nb_of_elem(0),_nb_of_elem_alloc(0),_ownership(false),_dealloc(0),_param_for_deallocator(0) { }
- MEDCOUPLING_EXPORT MemArray(const MemArray<T>& other);
- MEDCOUPLING_EXPORT bool isNull() const { return _pointer.isNull(); }
- MEDCOUPLING_EXPORT const T *getConstPointerLoc(std::size_t offset) const { return _pointer.getConstPointerLoc(offset); }
- MEDCOUPLING_EXPORT const T *getConstPointer() const { return _pointer.getConstPointer(); }
- MEDCOUPLING_EXPORT std::size_t getNbOfElem() const { return _nb_of_elem; }
- MEDCOUPLING_EXPORT std::size_t getNbOfElemAllocated() const { return _nb_of_elem_alloc; }
- MEDCOUPLING_EXPORT T *getPointer() { return _pointer.getPointer(); }
- MEDCOUPLING_EXPORT MemArray<T> &operator=(const MemArray<T>& other);
- MEDCOUPLING_EXPORT T operator[](std::size_t id) const { return _pointer.getConstPointer()[id]; }
- MEDCOUPLING_EXPORT T& operator[](std::size_t id) { return _pointer.getPointer()[id]; }
- MEDCOUPLING_EXPORT bool isEqual(const MemArray<T>& other, T prec, std::string& reason) const;
- MEDCOUPLING_EXPORT void repr(int sl, std::ostream& stream) const;
- MEDCOUPLING_EXPORT bool reprHeader(int sl, std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprZip(int sl, std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprNotTooLong(int sl, std::ostream& stream) const;
- MEDCOUPLING_EXPORT void fillWithValue(const T& val);
- MEDCOUPLING_EXPORT T *fromNoInterlace(int nbOfComp) const;
- MEDCOUPLING_EXPORT T *toNoInterlace(int nbOfComp) const;
- MEDCOUPLING_EXPORT void sort(bool asc);
- MEDCOUPLING_EXPORT void reverse(int nbOfComp);
- MEDCOUPLING_EXPORT void alloc(std::size_t nbOfElements);
- MEDCOUPLING_EXPORT void reserve(std::size_t newNbOfElements);
- MEDCOUPLING_EXPORT void reAlloc(std::size_t newNbOfElements);
- MEDCOUPLING_EXPORT void useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfElem);
- MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const T *array, std::size_t nbOfElem);
- MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, T element0, const T *others, std::size_t sizeOfOthers);
+ MEDCOUPLING_EXPORT MemArray(const MemArray<T>& other);
+ MEDCOUPLING_EXPORT bool isNull() const { return _pointer.isNull(); }
+ MEDCOUPLING_EXPORT const T *getConstPointerLoc(std::size_t offset) const { return _pointer.getConstPointerLoc(offset); }
+ MEDCOUPLING_EXPORT const T *getConstPointer() const { return _pointer.getConstPointer(); }
+ MEDCOUPLING_EXPORT std::size_t getNbOfElem() const { return _nb_of_elem; }
+ MEDCOUPLING_EXPORT std::size_t getNbOfElemAllocated() const { return _nb_of_elem_alloc; }
+ MEDCOUPLING_EXPORT T *getPointer() { return _pointer.getPointer(); }
+ MEDCOUPLING_EXPORT MemArray<T> &operator=(const MemArray<T>& other);
+ MEDCOUPLING_EXPORT T operator[](std::size_t id) const { return _pointer.getConstPointer()[id]; }
+ MEDCOUPLING_EXPORT T& operator[](std::size_t id) { return _pointer.getPointer()[id]; }
+ MEDCOUPLING_EXPORT bool isEqual(const MemArray<T>& other, T prec, std::string& reason) const;
+ MEDCOUPLING_EXPORT void repr(int sl, std::ostream& stream) const;
+ MEDCOUPLING_EXPORT bool reprHeader(int sl, std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprZip(int sl, std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprNotTooLong(int sl, std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void fillWithValue(const T& val);
+ MEDCOUPLING_EXPORT T *fromNoInterlace(int nbOfComp) const;
+ MEDCOUPLING_EXPORT T *toNoInterlace(int nbOfComp) const;
+ MEDCOUPLING_EXPORT void sort(bool asc);
+ MEDCOUPLING_EXPORT void reverse(int nbOfComp);
+ MEDCOUPLING_EXPORT void alloc(std::size_t nbOfElements);
+ MEDCOUPLING_EXPORT void reserve(std::size_t newNbOfElements);
+ MEDCOUPLING_EXPORT void reAlloc(std::size_t newNbOfElements);
+ MEDCOUPLING_EXPORT void useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfElem);
+ MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const T *array, std::size_t nbOfElem);
+ MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, T element0, const T *others, std::size_t sizeOfOthers);
template<class InputIterator>
void insertAtTheEnd(InputIterator first, InputIterator last);
- MEDCOUPLING_EXPORT void pushBack(T elem);
- MEDCOUPLING_EXPORT T popBack();
- MEDCOUPLING_EXPORT void pack() const;
- MEDCOUPLING_EXPORT bool isDeallocatorCalled() const { return _ownership; }
- MEDCOUPLING_EXPORT Deallocator getDeallocator() const { return _dealloc; }
- MEDCOUPLING_EXPORT void setSpecificDeallocator(Deallocator dealloc) { _dealloc=dealloc; }
- MEDCOUPLING_EXPORT void setParameterForDeallocator(void *param) { _param_for_deallocator=param; }
- MEDCOUPLING_EXPORT void *getParameterForDeallocator() const { return _param_for_deallocator; }
- MEDCOUPLING_EXPORT void destroy();
- MEDCOUPLING_EXPORT ~MemArray() { destroy(); }
+ MEDCOUPLING_EXPORT void pushBack(T elem);
+ MEDCOUPLING_EXPORT T popBack();
+ MEDCOUPLING_EXPORT void pack() const;
+ MEDCOUPLING_EXPORT bool isDeallocatorCalled() const { return _ownership; }
+ MEDCOUPLING_EXPORT Deallocator getDeallocator() const { return _dealloc; }
+ MEDCOUPLING_EXPORT void setSpecificDeallocator(Deallocator dealloc) { _dealloc=dealloc; }
+ MEDCOUPLING_EXPORT void setParameterForDeallocator(void *param) { _param_for_deallocator=param; }
+ MEDCOUPLING_EXPORT void *getParameterForDeallocator() const { return _param_for_deallocator; }
+ MEDCOUPLING_EXPORT void destroy();
+ MEDCOUPLING_EXPORT ~MemArray() { destroy(); }
public:
static void CPPDeallocator(void *pt, void *param);
static void CDeallocator(void *pt, void *param);