+namespace MEDCoupling
+{
+ class DataArrayInt32;
+
+ template<class T>
+ class DataArrayTemplate : public DataArray
+ {
+ public:
+ typedef T Type;
+ public:
+ MEDCOUPLING_EXPORT static MCAuto< typename Traits<T>::ArrayTypeCh > NewFromStdVector(const typename std::vector<T>& v);
+ MEDCOUPLING_EXPORT std::vector< MCAuto< typename Traits<T>::ArrayTypeCh > > explodeComponents() const;
+ //
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ MEDCOUPLING_EXPORT void updateTime() const { }
+ //
+ MEDCOUPLING_EXPORT std::size_t getNumberOfTuples() const { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
+ MEDCOUPLING_EXPORT std::size_t getNbOfElems() const { return _mem.getNbOfElem(); }
+ bool empty() const;
+ MEDCOUPLING_EXPORT void *getVoidStarPointer() { return getPointer(); }
+ MEDCOUPLING_EXPORT const T *getConstPointer() const { return _mem.getConstPointer(); }
+ MEDCOUPLING_EXPORT const T *begin() const { return getConstPointer(); }
+ MEDCOUPLING_EXPORT const T *end() const { return getConstPointer()+getNbOfElems(); }
+ void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1);
+ void useArray(const T *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
+ void useExternalArrayWithRWAccess(const T *array, int nbOfTuple, int nbOfCompo);
+ T getIJSafe(int tupleId, int compoId) const;
+ MEDCOUPLING_EXPORT T getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
+ MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
+ MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
+ MEDCOUPLING_EXPORT T *getPointer() { return _mem.getPointer(); declareAsNew(); }
+ void pack() const;
+ bool isAllocated() const;
+ void checkAllocated() const;
+ void desallocate();
+ void reserve(std::size_t nbOfElems);
+ void rearrange(int newNbOfCompo);
+ void transpose();
+ void pushBackSilent(T val);
+ void pushBackValsSilent(const T *valsBg, const T *valsEnd);
+ T popBackSilent();
+ T front() const;
+ T back() const;
+ std::size_t getNbOfElemAllocated() const { return _mem.getNbOfElemAllocated(); }
+ void allocIfNecessary(int nbOfTuple, int nbOfCompo);
+ void deepCopyFrom(const DataArrayTemplate<T>& other);
+ void reverse();
+ void fillWithValue(T val);
+ void reAlloc(std::size_t newNbOfTuple);
+ void renumberInPlace(const int *old2New);
+ void renumberInPlaceR(const int *new2Old);
+ void sort(bool asc=true);
+ typename Traits<T>::ArrayType *renumber(const int *old2New) const;
+ typename Traits<T>::ArrayType *renumberR(const int *new2Old) const;
+ typename Traits<T>::ArrayType *renumberAndReduce(const int *old2New, int newNbOfTuple) const;
+ typename Traits<T>::ArrayType *changeNbOfComponents(int newNbOfComp, T dftValue) const;
+ typename Traits<T>::ArrayType *subArray(int tupleIdBg, int tupleIdEnd=-1) const;
+ MCAuto<typename Traits<T>::ArrayTypeCh> selectPartDef(const PartDefinition* pd) const;
+ void circularPermutation(int nbOfShift=1);
+ void circularPermutationPerTuple(int nbOfShift=1);
+ void reversePerTuple();
+ void setPartOfValues1(const typename Traits<T>::ArrayType *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
+ void setPartOfValuesSimple1(T a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp);
+ void setPartOfValues2(const typename Traits<T>::ArrayType *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true);
+ void setPartOfValuesSimple2(T a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp);
+ void setPartOfValues3(const typename Traits<T>::ArrayType *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
+ void setPartOfValuesSimple3(T a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp);
+ void setPartOfValues4(const typename Traits<T>::ArrayType *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true);
+ void setPartOfValuesSimple4(T a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp);
+ void setPartOfValuesAdv(const typename Traits<T>::ArrayType *a, const DataArrayInt32 *tuplesSelec);
+ void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt32 *tuplesSelec);
+ void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step);
+ T getMaxValue(int& tupleId) const;
+ T getMaxValueInArray() const;
+ T getMaxAbsValue(std::size_t& tupleId) const;
+ T getMaxAbsValueInArray() const;
+ T getMinValue(int& tupleId) const;
+ T getMinValueInArray() const;
+ MEDCOUPLING_EXPORT void getTuple(int tupleId, T *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
+ template<class InputIterator>
+ void insertAtTheEnd(InputIterator first, InputIterator last);
+ MEDCOUPLING_EXPORT static void SetArrayIn(typename Traits<T>::ArrayType *newArray, typename Traits<T>::ArrayType* &arrayToSet);
+ MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, T element0, const T *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
+ MEDCOUPLING_EXPORT void fillWithZero();
+ public:
+ MEDCOUPLING_EXPORT MemArray<T>& accessToMemArray() { return _mem; }
+ MEDCOUPLING_EXPORT const MemArray<T>& accessToMemArray() const { return _mem; }
+ protected:
+ typename Traits<T>::ArrayType *mySelectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
+ typename Traits<T>::ArrayType *mySelectByTupleId(const DataArrayInt32& di) const;
+ typename Traits<T>::ArrayType *mySelectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const;
+ typename Traits<T>::ArrayType *myKeepSelectedComponents(const std::vector<int>& compoIds) const;
+ typename Traits<T>::ArrayType *mySelectByTupleIdSafeSlice(int bg, int end2, int step) const;
+ typename Traits<T>::ArrayType *mySelectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const;
+ protected:
+ MemArray<T> _mem;
+ };