Salome HOME
343859c4203a35ecedd4ea788f882ed52ac68970
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingMemArray.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __MEDCOUPLING_MEDCOUPLINGMEMARRAY_HXX__
22 #define __MEDCOUPLING_MEDCOUPLINGMEMARRAY_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MCAuto.hxx"
26 #include "MEDCouplingTimeLabel.hxx"
27 #include "MEDCouplingRefCountObject.hxx"
28 #include "InterpKernelException.hxx"
29 #include "MEDCouplingTraits.hxx"
30 #include "BBTreePts.txx"
31
32 #include <string>
33 #include <vector>
34 #include <iterator>
35
36 namespace MEDCoupling
37 {
38   typedef enum
39     {
40       AX_CART = 3,
41       AX_CYL = 4,
42       AX_SPHER = 5
43     } MEDCouplingAxisType;
44   // -- WARNING this enum must be synchronized with MEDCouplingCommon.i file ! --
45
46   class PartDefinition;
47   
48   template<class T>
49   class MEDCouplingPointer
50   {
51   public:
52     MEDCouplingPointer():_internal(0),_external(0) { }
53     void null() { _internal=0; _external=0; }
54     bool isNull() const { return _internal==0 && _external==0; }
55     void setInternal(T *pointer);
56     void setExternal(const T *pointer);
57     const T *getConstPointer() const { if(_internal) return _internal; else return _external; }
58     const T *getConstPointerLoc(std::size_t offset) const { if(_internal) return _internal+offset; else return _external+offset; }
59     T *getPointer() { if(_internal) return _internal; if(_external) throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); else return 0; }
60   private:
61     T *_internal;
62     const T *_external;
63   };
64
65   template<class T>
66   class MemArray
67   {
68   public:
69     typedef void (*Deallocator)(void *,void *);
70   public:
71     MemArray():_nb_of_elem(0),_nb_of_elem_alloc(0),_ownership(false),_dealloc(0),_param_for_deallocator(0) { }
72     MemArray(const MemArray<T>& other);
73     bool isNull() const { return _pointer.isNull(); }
74     const T *getConstPointerLoc(std::size_t offset) const { return _pointer.getConstPointerLoc(offset); }
75     const T *getConstPointer() const { return _pointer.getConstPointer(); }
76     std::size_t getNbOfElem() const { return _nb_of_elem; }
77     std::size_t getNbOfElemAllocated() const { return _nb_of_elem_alloc; }
78     T *getPointer() { return _pointer.getPointer(); }
79     MemArray<T> &operator=(const MemArray<T>& other);
80     T operator[](std::size_t id) const { return _pointer.getConstPointer()[id]; }
81     T& operator[](std::size_t id) { return _pointer.getPointer()[id]; }
82     bool isEqual(const MemArray<T>& other, T prec, std::string& reason) const;
83     void repr(int sl, std::ostream& stream) const;
84     bool reprHeader(int sl, std::ostream& stream) const;
85     void reprZip(int sl, std::ostream& stream) const;
86     void reprNotTooLong(int sl, std::ostream& stream) const;
87     void fillWithValue(const T& val);
88     T *fromNoInterlace(int nbOfComp) const;
89     T *toNoInterlace(int nbOfComp) const;
90     void sort(bool asc);
91     void reverse(int nbOfComp);
92     void alloc(std::size_t nbOfElements);
93     void reserve(std::size_t newNbOfElements);
94     void reAlloc(std::size_t newNbOfElements);
95     void useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfElem);
96     void useExternalArrayWithRWAccess(const T *array, std::size_t nbOfElem);
97     void writeOnPlace(std::size_t id, T element0, const T *others, std::size_t sizeOfOthers);
98     template<class InputIterator>
99     void insertAtTheEnd(InputIterator first, InputIterator last);
100     void pushBack(T elem);
101     T popBack();
102     void pack() const;
103     bool isDeallocatorCalled() const { return _ownership; }
104     Deallocator getDeallocator() const { return _dealloc; }
105     void setSpecificDeallocator(Deallocator dealloc) { _dealloc=dealloc; }
106     void setParameterForDeallocator(void *param) { _param_for_deallocator=param; }
107     void *getParameterForDeallocator() const { return _param_for_deallocator; }
108     void destroy();
109     ~MemArray() { destroy(); }
110   public:
111     static void CPPDeallocator(void *pt, void *param);
112     static void CDeallocator(void *pt, void *param);
113   private:
114     static void DestroyPointer(T *pt, Deallocator dealloc, void *param);
115     static Deallocator BuildFromType(DeallocType type);
116   private:
117     std::size_t _nb_of_elem;
118     std::size_t _nb_of_elem_alloc;
119     bool _ownership;
120     MEDCouplingPointer<T> _pointer;
121     Deallocator _dealloc;
122     void *_param_for_deallocator;
123   };
124
125   class DataArrayInt;
126   class DataArrayByte;
127
128   class DataArray : public RefCountObject, public TimeLabel
129   {
130   public:
131     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
132     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
133     MEDCOUPLING_EXPORT void setName(const std::string& name);
134     MEDCOUPLING_EXPORT void copyStringInfoFrom(const DataArray& other);
135     MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds);
136     MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other);
137     MEDCOUPLING_EXPORT bool areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const;
138     MEDCOUPLING_EXPORT bool areInfoEquals(const DataArray& other) const;
139     MEDCOUPLING_EXPORT std::string cppRepr(const std::string& varName) const;
140     MEDCOUPLING_EXPORT std::string getName() const { return _name; }
141     MEDCOUPLING_EXPORT const std::vector<std::string> &getInfoOnComponents() const { return _info_on_compo; }
142     MEDCOUPLING_EXPORT std::vector<std::string> &getInfoOnComponents() { return _info_on_compo; }
143     MEDCOUPLING_EXPORT void setInfoOnComponents(const std::vector<std::string>& info);
144     MEDCOUPLING_EXPORT void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info);
145     MEDCOUPLING_EXPORT std::vector<std::string> getVarsOnComponent() const;
146     MEDCOUPLING_EXPORT std::vector<std::string> getUnitsOnComponent() const;
147     MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const;
148     MEDCOUPLING_EXPORT std::string getVarOnComponent(int i) const;
149     MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const;
150     MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const std::string& info);
151     MEDCOUPLING_EXPORT std::size_t getNumberOfComponents() const { return _info_on_compo.size(); }
152     MEDCOUPLING_EXPORT void setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
153     MEDCOUPLING_EXPORT virtual void *getVoidStarPointer() = 0;
154     MEDCOUPLING_EXPORT virtual DataArray *deepCopy() const = 0;
155     MEDCOUPLING_EXPORT virtual DataArray *buildNewEmptyInstance() const = 0;
156     MEDCOUPLING_EXPORT virtual bool isAllocated() const = 0;
157     MEDCOUPLING_EXPORT virtual void checkAllocated() const = 0;
158     MEDCOUPLING_EXPORT virtual void desallocate() = 0;
159     MEDCOUPLING_EXPORT virtual int getNumberOfTuples() const = 0;
160     MEDCOUPLING_EXPORT virtual std::size_t getNbOfElems() const = 0;
161     MEDCOUPLING_EXPORT virtual std::size_t getNbOfElemAllocated() const = 0;
162     MEDCOUPLING_EXPORT virtual void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1) = 0;
163     MEDCOUPLING_EXPORT virtual void reAlloc(std::size_t newNbOfTuple) = 0;
164     MEDCOUPLING_EXPORT virtual void renumberInPlace(const int *old2New) = 0;
165     MEDCOUPLING_EXPORT virtual void renumberInPlaceR(const int *new2Old) = 0;
166     MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) = 0;
167     MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) = 0;
168     MEDCOUPLING_EXPORT virtual DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const = 0;
169     MEDCOUPLING_EXPORT virtual DataArray *keepSelectedComponents(const std::vector<int>& compoIds) const = 0;
170     MEDCOUPLING_EXPORT virtual DataArray *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const = 0;
171     MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const = 0;
172     MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafeSlice(int bg, int end2, int step) const = 0;
173     MEDCOUPLING_EXPORT virtual void rearrange(int newNbOfCompo) = 0;
174     MEDCOUPLING_EXPORT virtual void circularPermutation(int nbOfShift=1) = 0;
175     MEDCOUPLING_EXPORT virtual void circularPermutationPerTuple(int nbOfShift=1) = 0;
176     MEDCOUPLING_EXPORT virtual void reversePerTuple() = 0;
177     MEDCOUPLING_EXPORT void checkNbOfTuples(int nbOfTuples, const std::string& msg) const;
178     MEDCOUPLING_EXPORT void checkNbOfComps(int nbOfCompo, const std::string& msg) const;
179     MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const;
180     MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const;
181     MEDCOUPLING_EXPORT void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const;
182     MEDCOUPLING_EXPORT static void GetSlice(int start, int stop, int step, int sliceId, int nbOfSlices, int& startSlice, int& stopSlice);
183     MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg);
184     MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg);
185     MEDCOUPLING_EXPORT static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step);
186     MEDCOUPLING_EXPORT static std::string GetVarNameFromInfo(const std::string& info);
187     MEDCOUPLING_EXPORT static std::string GetUnitFromInfo(const std::string& info);
188     MEDCOUPLING_EXPORT static std::string BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit);
189     MEDCOUPLING_EXPORT static std::string GetAxisTypeRepr(MEDCouplingAxisType at);
190     MEDCOUPLING_EXPORT static DataArray *Aggregate(const std::vector<const DataArray *>& arrs);
191     MEDCOUPLING_EXPORT virtual void reprStream(std::ostream& stream) const = 0;
192     MEDCOUPLING_EXPORT virtual void reprZipStream(std::ostream& stream) const = 0;
193     MEDCOUPLING_EXPORT virtual void reprWithoutNameStream(std::ostream& stream) const;
194     MEDCOUPLING_EXPORT virtual void reprZipWithoutNameStream(std::ostream& stream) const = 0;
195     MEDCOUPLING_EXPORT virtual void reprCppStream(const std::string& varName, std::ostream& stream) const = 0;
196     MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const = 0;
197     MEDCOUPLING_EXPORT virtual void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const = 0;
198   protected:
199     DataArray() { }
200     ~DataArray() { }
201   protected:
202     MEDCOUPLING_EXPORT static void CheckValueInRange(int ref, int value, const std::string& msg);
203     MEDCOUPLING_EXPORT static void CheckValueInRangeEx(int value, int start, int end, const std::string& msg);
204     MEDCOUPLING_EXPORT static void CheckClosingParInRange(int ref, int value, const std::string& msg);
205     MEDCOUPLING_EXPORT static int EffectiveCircPerm(int nbOfShift, int nbOfTuples);
206   protected:
207     std::string _name;
208     std::vector<std::string> _info_on_compo;
209   };
210 }
211
212 namespace MEDCoupling
213 {
214   class DataArrayInt;
215
216   template<class T>
217   class DataArrayTemplate : public DataArray
218   {
219   public:
220     MEDCOUPLING_EXPORT static MCAuto< typename Traits<T>::ArrayTypeCh > NewFromStdVector(const typename std::vector<T>& v);
221     MEDCOUPLING_EXPORT std::vector< MCAuto< typename Traits<T>::ArrayTypeCh > > explodeComponents() const;
222     //
223     std::size_t getHeapMemorySizeWithoutChildren() const;
224     MEDCOUPLING_EXPORT void updateTime() const { }
225     //
226     MEDCOUPLING_EXPORT int getNumberOfTuples() const { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
227     MEDCOUPLING_EXPORT std::size_t getNbOfElems() const { return _mem.getNbOfElem(); }
228     bool empty() const;
229     MEDCOUPLING_EXPORT void *getVoidStarPointer() { return getPointer(); }
230     MEDCOUPLING_EXPORT const T *getConstPointer() const { return _mem.getConstPointer(); }
231     MEDCOUPLING_EXPORT const T *begin() const { return getConstPointer(); }
232     MEDCOUPLING_EXPORT const T *end() const { return getConstPointer()+getNbOfElems(); }
233     void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1);
234     void useArray(const T *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
235     void useExternalArrayWithRWAccess(const T *array, int nbOfTuple, int nbOfCompo);
236     T getIJSafe(int tupleId, int compoId) const;
237     MEDCOUPLING_EXPORT T getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
238     MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
239     MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
240     MEDCOUPLING_EXPORT T *getPointer() { return _mem.getPointer(); declareAsNew(); }
241     void pack() const;
242     bool isAllocated() const;
243     void checkAllocated() const;
244     void desallocate();
245     void reserve(std::size_t nbOfElems);
246     void rearrange(int newNbOfCompo);
247     void transpose();
248     void pushBackSilent(T val);
249     void pushBackValsSilent(const T *valsBg, const T *valsEnd);
250     T popBackSilent();
251     T front() const;
252     T back() const;
253     std::size_t getNbOfElemAllocated() const { return _mem.getNbOfElemAllocated(); }
254     void allocIfNecessary(int nbOfTuple, int nbOfCompo);
255     void deepCopyFrom(const DataArrayTemplate<T>& other);
256     void reverse();
257     void fillWithValue(T val);
258     void reAlloc(std::size_t newNbOfTuple);
259     void renumberInPlace(const int *old2New);
260     void renumberInPlaceR(const int *new2Old);
261     void sort(bool asc=true);
262     typename Traits<T>::ArrayType *renumber(const int *old2New) const;
263     typename Traits<T>::ArrayType *renumberR(const int *new2Old) const;
264     typename Traits<T>::ArrayType *renumberAndReduce(const int *old2New, int newNbOfTuple) const;
265     typename Traits<T>::ArrayType *changeNbOfComponents(int newNbOfComp, T dftValue) const;
266     typename Traits<T>::ArrayType *subArray(int tupleIdBg, int tupleIdEnd=-1) const;
267     MCAuto<typename Traits<T>::ArrayTypeCh> selectPartDef(const PartDefinition* pd) const;
268     void circularPermutation(int nbOfShift=1);
269     void circularPermutationPerTuple(int nbOfShift=1);
270     void reversePerTuple();
271     void setPartOfValues1(const typename Traits<T>::ArrayType *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
272     void setPartOfValuesSimple1(T a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp);
273     void setPartOfValues2(const typename Traits<T>::ArrayType *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true);
274     void setPartOfValuesSimple2(T a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp);
275     void setPartOfValues3(const typename Traits<T>::ArrayType *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
276     void setPartOfValuesSimple3(T a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp);
277     void setPartOfValues4(const typename Traits<T>::ArrayType *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true);
278     void setPartOfValuesSimple4(T a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp);
279     void setPartOfValuesAdv(const typename Traits<T>::ArrayType *a, const DataArrayInt *tuplesSelec);
280     void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec);
281     void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step);
282     T getMaxValue(int& tupleId) const;
283     T getMaxValueInArray() const;
284     T getMinValue(int& tupleId) const;
285     T getMinValueInArray() const;
286   public:
287     MEDCOUPLING_EXPORT MemArray<T>& accessToMemArray() { return _mem; }
288     MEDCOUPLING_EXPORT const MemArray<T>& accessToMemArray() const { return _mem; }
289   protected:
290     typename Traits<T>::ArrayType *mySelectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
291     typename Traits<T>::ArrayType *mySelectByTupleId(const DataArrayInt& di) const;
292     typename Traits<T>::ArrayType *mySelectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const;
293     typename Traits<T>::ArrayType *myKeepSelectedComponents(const std::vector<int>& compoIds) const;
294     typename Traits<T>::ArrayType *mySelectByTupleIdSafeSlice(int bg, int end2, int step) const;
295     typename Traits<T>::ArrayType *mySelectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const;
296   protected:
297     MemArray<T> _mem;
298   };
299
300   template<class T>
301   class DataArrayTemplateClassic : public DataArrayTemplate<T>
302   {
303   public:
304     MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> convertToDblArr() const;
305     MEDCOUPLING_EXPORT MCAuto<DataArrayInt> convertToIntArr() const;
306     MEDCOUPLING_EXPORT MCAuto<DataArrayFloat> convertToFloatArr() const;
307   protected:
308     static typename Traits<T>::ArrayType *PerformCopyOrIncrRef(bool dCpy, const typename Traits<T>::ArrayType& self);
309   private:
310     template<class U>
311     MCAuto< typename Traits<U>::ArrayType > convertToOtherTypeOfArr() const;
312   };
313   
314   template<class T>
315   class DataArrayTemplateFP : public DataArrayTemplateClassic<T>
316   {
317   public:
318     MEDCOUPLING_EXPORT bool isUniform(T val, T eps) const;
319     MEDCOUPLING_EXPORT void iota(T init=0.);
320   };
321 }
322
323 namespace MEDCoupling
324 {
325   class DataArrayFloatIterator;
326   class DataArrayFloat : public DataArrayTemplateFP<float>
327   {
328   public:
329     MEDCOUPLING_EXPORT static DataArrayFloat *New();
330   public:// abstract method overload
331     MEDCOUPLING_EXPORT DataArrayFloat *deepCopy() const;
332     MEDCOUPLING_EXPORT DataArrayFloat *buildNewEmptyInstance() const { return DataArrayFloat::New(); }
333     MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplateFP<float>::mySelectByTupleRanges(ranges); }
334     MEDCOUPLING_EXPORT DataArrayFloat *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplateFP<float>::myKeepSelectedComponents(compoIds); }
335     MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<float>::mySelectByTupleId(new2OldBg,new2OldEnd); }
336     MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<float>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
337     MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplateFP<float>::mySelectByTupleIdSafeSlice(bg,end2,step); }
338     MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
339     MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
340     MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
341     MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
342     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
343     MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
344   public:// non abstract but essential
345     MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
346     MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
347     MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
348     MEDCOUPLING_EXPORT bool isEqual(const DataArrayFloat& other, float prec) const;
349     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayFloat& other, float prec, std::string& reason) const;
350     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayFloat& other, float prec) const;
351     MEDCOUPLING_EXPORT DataArrayFloat *performCopyOrIncrRef(bool deepCopy) const;
352   public:
353     MEDCOUPLING_EXPORT DataArrayFloatIterator *iterator();
354   private:
355     ~DataArrayFloat() { }
356     DataArrayFloat() { }
357   };
358 }
359
360 namespace MEDCoupling
361 {
362   class DataArrayDoubleIterator;
363   class DataArrayDouble : public DataArrayTemplateFP<double>
364   {
365   public:
366     MEDCOUPLING_EXPORT static DataArrayDouble *New();
367     MEDCOUPLING_EXPORT double doubleValue() const;
368     MEDCOUPLING_EXPORT DataArrayDouble *deepCopy() const;
369     MEDCOUPLING_EXPORT DataArrayDouble *buildNewEmptyInstance() const { return DataArrayDouble::New(); }
370     MEDCOUPLING_EXPORT DataArrayDouble *performCopyOrIncrRef(bool deepCopy) const;
371     MEDCOUPLING_EXPORT void fillWithZero();
372     MEDCOUPLING_EXPORT void checkMonotonic(bool increasing, double eps) const;
373     MEDCOUPLING_EXPORT bool isMonotonic(bool increasing, double eps) const;
374     MEDCOUPLING_EXPORT std::string repr() const;
375     MEDCOUPLING_EXPORT std::string reprZip() const;
376     MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
377     MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& nameInFile, DataArrayByte *byteArr) const;
378     MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
379     MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
380     MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
381     MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
382     MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
383     MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
384     MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
385     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
386     MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
387     MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const;
388     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const;
389     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const;
390     MEDCOUPLING_EXPORT DataArrayDouble *fromNoInterlace() const;
391     MEDCOUPLING_EXPORT DataArrayDouble *toNoInterlace() const;
392     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<double>::mySelectByTupleId(new2OldBg,new2OldEnd); }
393     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const DataArrayInt& di) const { return DataArrayTemplateFP<double>::mySelectByTupleId(di); }
394     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<double>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
395     MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplateFP<double>::myKeepSelectedComponents(compoIds); }
396     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplateFP<double>::mySelectByTupleIdSafeSlice(bg,end2,step); }
397     MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplateFP<double>::mySelectByTupleRanges(ranges); }
398     MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other);
399     MEDCOUPLING_EXPORT bool areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt *&tupleIds) const;
400     MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const;
401     MEDCOUPLING_EXPORT double minimalDistanceTo(const DataArrayDouble *other, int& thisTupleId, int& otherTupleId) const;
402     MEDCOUPLING_EXPORT DataArrayDouble *duplicateEachTupleNTimes(int nbTimes) const;
403     MEDCOUPLING_EXPORT DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const;
404     MEDCOUPLING_EXPORT DataArrayInt *findClosestTupleId(const DataArrayDouble *other) const;
405     MEDCOUPLING_EXPORT DataArrayInt *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const;
406     MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds);
407     MEDCOUPLING_EXPORT void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
408     MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
409     MEDCOUPLING_EXPORT DataArrayDoubleIterator *iterator();
410     template<class InputIterator>
411     void insertAtTheEnd(InputIterator first, InputIterator last);
412     MEDCOUPLING_EXPORT void aggregate(const DataArrayDouble *other);
413     MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
414     MEDCOUPLING_EXPORT void checkNoNullValues() const;
415     MEDCOUPLING_EXPORT void getMinMaxPerComponent(double *bounds) const;
416     MEDCOUPLING_EXPORT DataArrayDouble *computeBBoxPerTuple(double epsilon=0.0) const;
417     MEDCOUPLING_EXPORT void computeTupleIdsNearTuples(const DataArrayDouble *other, double eps, DataArrayInt *& c, DataArrayInt *& cI) const;
418     MEDCOUPLING_EXPORT void recenterForMaxPrecision(double eps);
419     MEDCOUPLING_EXPORT double getMaxValue2(DataArrayInt*& tupleIds) const;
420     MEDCOUPLING_EXPORT double getMinValue2(DataArrayInt*& tupleIds) const;
421     MEDCOUPLING_EXPORT int count(double value, double eps) const;
422     MEDCOUPLING_EXPORT double getAverageValue() const;
423     MEDCOUPLING_EXPORT double norm2() const;
424     MEDCOUPLING_EXPORT double normMax() const;
425     MEDCOUPLING_EXPORT double normMin() const;
426     MEDCOUPLING_EXPORT void accumulate(double *res) const;
427     MEDCOUPLING_EXPORT double accumulate(int compId) const;
428     MEDCOUPLING_EXPORT DataArrayDouble *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const;
429     MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> cumSum() const;
430     MEDCOUPLING_EXPORT double distanceToTuple(const double *tupleBg, const double *tupleEnd, int& tupleId) const;
431     MEDCOUPLING_EXPORT DataArrayDouble *fromPolarToCart() const;
432     MEDCOUPLING_EXPORT DataArrayDouble *fromCylToCart() const;
433     MEDCOUPLING_EXPORT DataArrayDouble *fromSpherToCart() const;
434     MEDCOUPLING_EXPORT DataArrayDouble *cartesianize(MEDCouplingAxisType atOfThis) const;
435     MEDCOUPLING_EXPORT DataArrayDouble *fromCartToPolar() const;
436     MEDCOUPLING_EXPORT DataArrayDouble *fromCartToCyl() const;
437     MEDCOUPLING_EXPORT DataArrayDouble *fromCartToSpher() const;
438     MEDCOUPLING_EXPORT DataArrayDouble *fromCartToCylGiven(const DataArrayDouble *coords, const double center[3], const double vect[3]) const;
439     MEDCOUPLING_EXPORT DataArrayDouble *doublyContractedProduct() const;
440     MEDCOUPLING_EXPORT DataArrayDouble *determinant() const;
441     MEDCOUPLING_EXPORT DataArrayDouble *eigenValues() const;
442     MEDCOUPLING_EXPORT DataArrayDouble *eigenVectors() const;
443     MEDCOUPLING_EXPORT DataArrayDouble *inverse() const;
444     MEDCOUPLING_EXPORT DataArrayDouble *trace() const;
445     MEDCOUPLING_EXPORT DataArrayDouble *deviator() const;
446     MEDCOUPLING_EXPORT DataArrayDouble *magnitude() const;
447     MEDCOUPLING_EXPORT DataArrayDouble *sumPerTuple() const;
448     MEDCOUPLING_EXPORT DataArrayDouble *maxPerTuple() const;
449     MEDCOUPLING_EXPORT DataArrayDouble *maxPerTupleWithCompoId(DataArrayInt* &compoIdOfMaxPerTuple) const;
450     MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrix() const;
451     MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble *other) const;
452     MEDCOUPLING_EXPORT void sortPerTuple(bool asc);
453     MEDCOUPLING_EXPORT void abs();
454     MEDCOUPLING_EXPORT DataArrayDouble *computeAbs() const;
455     MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId);
456     MEDCOUPLING_EXPORT void applyLin(double a, double b);
457     MEDCOUPLING_EXPORT void applyInv(double numerator);
458     MEDCOUPLING_EXPORT void applyPow(double val);
459     MEDCOUPLING_EXPORT void applyRPow(double val);
460     MEDCOUPLING_EXPORT DataArrayDouble *negate() const;
461     MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const;
462     MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, const std::string& func, bool isSafe=true) const;
463     MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(const std::string& func, bool isSafe=true) const;
464     MEDCOUPLING_EXPORT void applyFuncOnThis(const std::string& func, bool isSafe=true);
465     MEDCOUPLING_EXPORT DataArrayDouble *applyFuncCompo(int nbOfComp, const std::string& func, bool isSafe=true) const;
466     MEDCOUPLING_EXPORT DataArrayDouble *applyFuncNamedCompo(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func, bool isSafe=true) const;
467     MEDCOUPLING_EXPORT void applyFuncFast32(const std::string& func);
468     MEDCOUPLING_EXPORT void applyFuncFast64(const std::string& func);
469     MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> symmetry3DPlane(const double point[3], const double normalVector[3]) const;
470     MEDCOUPLING_EXPORT DataArrayInt *findIdsInRange(double vmin, double vmax) const;
471     MEDCOUPLING_EXPORT DataArrayInt *findIdsNotInRange(double vmin, double vmax) const;
472     MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2);
473     MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const std::vector<const DataArrayDouble *>& arr);
474     MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2);
475     MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const std::vector<const DataArrayDouble *>& arr);
476     MEDCOUPLING_EXPORT static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2);
477     MEDCOUPLING_EXPORT static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2);
478     MEDCOUPLING_EXPORT static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2);
479     MEDCOUPLING_EXPORT static DataArrayDouble *Min(const DataArrayDouble *a1, const DataArrayDouble *a2);
480     MEDCOUPLING_EXPORT static DataArrayDouble *Add(const DataArrayDouble *a1, const DataArrayDouble *a2);
481     MEDCOUPLING_EXPORT void addEqual(const DataArrayDouble *other);
482     MEDCOUPLING_EXPORT static DataArrayDouble *Substract(const DataArrayDouble *a1, const DataArrayDouble *a2);
483     MEDCOUPLING_EXPORT void substractEqual(const DataArrayDouble *other);
484     MEDCOUPLING_EXPORT static DataArrayDouble *Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2);
485     MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayDouble *other);
486     MEDCOUPLING_EXPORT static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2);
487     MEDCOUPLING_EXPORT void divideEqual(const DataArrayDouble *other);
488     MEDCOUPLING_EXPORT static DataArrayDouble *Pow(const DataArrayDouble *a1, const DataArrayDouble *a2);
489     MEDCOUPLING_EXPORT void powEqual(const DataArrayDouble *other);
490     MEDCOUPLING_EXPORT std::vector<bool> toVectorOfBool(double eps) const;
491     MEDCOUPLING_EXPORT static void Rotate2DAlg(const double *center, double angle, int nbNodes, const double *coordsIn, double *coordsOut);
492     MEDCOUPLING_EXPORT static void Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, const double *coordsIn, double *coordsOut);
493     MEDCOUPLING_EXPORT static void Symmetry3DPlane(const double point[3], const double normalVector[3], int nbNodes, const double *coordsIn, double *coordsOut);
494     MEDCOUPLING_EXPORT static void GiveBaseForPlane(const double normalVector[3], double baseOfPlane[9]);
495   public:
496     MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
497     MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
498     MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
499     MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
500   public:
501     template<int SPACEDIM>
502     void findCommonTuplesAlg(const double *bbox, int nbNodes, int limitNodeId, double prec, DataArrayInt *c, DataArrayInt *cI) const;
503     template<int SPACEDIM>
504     static void FindClosestTupleIdAlg(const BBTreePts<SPACEDIM,int>& myTree, double dist, const double *pos, int nbOfTuples, const double *thisPt, int thisNbOfTuples, int *res);
505     template<int SPACEDIM>
506     static void FindTupleIdsNearTuplesAlg(const BBTreePts<SPACEDIM,int>& myTree, const double *pos, int nbOfTuples, double eps,
507                                           DataArrayInt *c, DataArrayInt *cI);
508   private:
509     ~DataArrayDouble() { }
510     DataArrayDouble() { }
511   };
512
513   class DataArrayIntIterator;
514
515   class DataArrayInt : public DataArrayTemplateClassic<int>
516   {
517   public:
518     MEDCOUPLING_EXPORT static DataArrayInt *New();
519     MEDCOUPLING_EXPORT int intValue() const;
520     MEDCOUPLING_EXPORT int getHashCode() const;
521     MEDCOUPLING_EXPORT DataArrayInt *deepCopy() const;
522     MEDCOUPLING_EXPORT DataArrayInt *performCopyOrIncrRef(bool deepCopy) const;
523     MEDCOUPLING_EXPORT DataArrayInt *buildNewEmptyInstance() const { return DataArrayInt::New(); }
524     MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const;
525     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayInt& other, std::string& reason) const;
526     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayInt& other) const;
527     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const;
528     MEDCOUPLING_EXPORT bool isFittingWith(const std::vector<bool>& v) const;
529     MEDCOUPLING_EXPORT void switchOnTupleEqualTo(int val, std::vector<bool>& vec) const;
530     MEDCOUPLING_EXPORT void switchOnTupleNotEqualTo(int val, std::vector<bool>& vec) const;
531     MEDCOUPLING_EXPORT DataArrayInt *buildPermutationArr(const DataArrayInt& other) const;
532     MEDCOUPLING_EXPORT DataArrayInt *indicesOfSubPart(const DataArrayInt& partOfThis) const;
533     MEDCOUPLING_EXPORT DataArrayInt *sumPerTuple() const;
534     MEDCOUPLING_EXPORT void checkMonotonic(bool increasing) const;
535     MEDCOUPLING_EXPORT bool isMonotonic(bool increasing) const;
536     MEDCOUPLING_EXPORT void checkStrictlyMonotonic(bool increasing) const;
537     MEDCOUPLING_EXPORT bool isStrictlyMonotonic(bool increasing) const;
538     MEDCOUPLING_EXPORT void fillWithZero();
539     MEDCOUPLING_EXPORT void iota(int init=0);
540     MEDCOUPLING_EXPORT std::string repr() const;
541     MEDCOUPLING_EXPORT std::string reprZip() const;
542     MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
543     MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const;
544     MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
545     MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
546     MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
547     MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
548     MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
549     MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
550     MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
551     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
552     MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
553     MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd);
554     MEDCOUPLING_EXPORT DataArrayInt *transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const;
555     MEDCOUPLING_EXPORT void splitByValueRange(const int *arrBg, const int *arrEnd,
556                                               DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const;
557     MEDCOUPLING_EXPORT bool isRange(int& strt, int& sttoopp, int& stteepp) const;
558     MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const;
559     MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const;
560     MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const;
561     MEDCOUPLING_EXPORT DataArrayInt *fromNoInterlace() const;
562     MEDCOUPLING_EXPORT DataArrayInt *toNoInterlace() const;
563     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<int>::mySelectByTupleId(new2OldBg,new2OldEnd); }
564     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const DataArrayInt& di) const { return DataArrayTemplate<int>::mySelectByTupleId(di); }
565     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<int>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
566     MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<int>::myKeepSelectedComponents(compoIds); }
567     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate<int>::mySelectByTupleIdSafeSlice(bg,end2,step); }
568     MEDCOUPLING_EXPORT DataArrayInt *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<int>::mySelectByTupleRanges(ranges); }
569     MEDCOUPLING_EXPORT DataArrayInt *checkAndPreparePermutation() const;
570     MEDCOUPLING_EXPORT static DataArrayInt *FindPermutationFromFirstToSecond(const DataArrayInt *ids1, const DataArrayInt *ids2);
571     MEDCOUPLING_EXPORT void changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const;
572     MEDCOUPLING_EXPORT static DataArrayInt *ConvertIndexArrayToO2N(int nbOfOldTuples, const int *arr, const int *arrIBg, const int *arrIEnd, int &newNbOfTuples);
573     MEDCOUPLING_EXPORT DataArrayInt *buildPermArrPerLevel() const;
574     MEDCOUPLING_EXPORT bool isIota(int sizeExpected) const;
575     MEDCOUPLING_EXPORT bool isUniform(int val) const;
576     MEDCOUPLING_EXPORT bool hasUniqueValues() const;
577     MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other);
578     MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds);
579     MEDCOUPLING_EXPORT void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
580     MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
581     MEDCOUPLING_EXPORT DataArrayIntIterator *iterator();
582     MEDCOUPLING_EXPORT DataArrayInt *findIdsEqual(int val) const;
583     MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqual(int val) const;
584     MEDCOUPLING_EXPORT DataArrayInt *findIdsEqualList(const int *valsBg, const int *valsEnd) const;
585     MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqualList(const int *valsBg, const int *valsEnd) const;
586     MEDCOUPLING_EXPORT DataArrayInt *findIdsEqualTuple(const int *tupleBg, const int *tupleEnd) const;
587     MEDCOUPLING_EXPORT int changeValue(int oldValue, int newValue);
588     MEDCOUPLING_EXPORT int findIdFirstEqualTuple(const std::vector<int>& tupl) const;
589     MEDCOUPLING_EXPORT int findIdFirstEqual(int value) const;
590     MEDCOUPLING_EXPORT int findIdFirstEqual(const std::vector<int>& vals) const;
591     MEDCOUPLING_EXPORT int findIdSequence(const std::vector<int>& vals) const;
592     MEDCOUPLING_EXPORT bool presenceOfTuple(const std::vector<int>& tupl) const;
593     MEDCOUPLING_EXPORT bool presenceOfValue(int value) const;
594     MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector<int>& vals) const;
595     MEDCOUPLING_EXPORT int count(int value) const;
596     MEDCOUPLING_EXPORT void accumulate(int *res) const;
597     MEDCOUPLING_EXPORT int accumulate(int compId) const;
598     MEDCOUPLING_EXPORT DataArrayInt *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const;
599     MEDCOUPLING_EXPORT void getMinMaxValues(int& minValue, int& maxValue) const;
600     MEDCOUPLING_EXPORT void abs();
601     MEDCOUPLING_EXPORT DataArrayInt *computeAbs() const;
602     MEDCOUPLING_EXPORT void applyLin(int a, int b, int compoId);
603     MEDCOUPLING_EXPORT void applyLin(int a, int b);
604     MEDCOUPLING_EXPORT void applyInv(int numerator);
605     MEDCOUPLING_EXPORT DataArrayInt *negate() const;
606     MEDCOUPLING_EXPORT void applyDivideBy(int val);
607     MEDCOUPLING_EXPORT void applyModulus(int val);
608     MEDCOUPLING_EXPORT void applyRModulus(int val);
609     MEDCOUPLING_EXPORT void applyPow(int val);
610     MEDCOUPLING_EXPORT void applyRPow(int val);
611     MEDCOUPLING_EXPORT DataArrayInt *findIdsInRange(int vmin, int vmax) const;
612     MEDCOUPLING_EXPORT DataArrayInt *findIdsNotInRange(int vmin, int vmax) const;
613     MEDCOUPLING_EXPORT DataArrayInt *findIdsStricltyNegative() const;
614     MEDCOUPLING_EXPORT bool checkAllIdsInRange(int vmin, int vmax) const;
615     MEDCOUPLING_EXPORT MCAuto<DataArrayInt> findIdsGreaterOrEqualTo(int val) const;
616     MEDCOUPLING_EXPORT MCAuto<DataArrayInt> findIdsGreaterThan(int val) const;
617     MEDCOUPLING_EXPORT MCAuto<DataArrayInt> findIdsLowerOrEqualTo(int val) const;
618     MEDCOUPLING_EXPORT MCAuto<DataArrayInt> findIdsLowerThan(int val) const;
619     MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2);
620     MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const std::vector<const DataArrayInt *>& arr);
621     MEDCOUPLING_EXPORT static DataArrayInt *AggregateIndexes(const std::vector<const DataArrayInt *>& arrs);
622     MEDCOUPLING_EXPORT static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2);
623     MEDCOUPLING_EXPORT static DataArrayInt *Meld(const std::vector<const DataArrayInt *>& arr);
624     MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
625     MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector<const DataArrayInt *>& arr);
626     MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector<const DataArrayInt *>& arr);
627     MEDCOUPLING_EXPORT static DataArrayInt *BuildListOfSwitchedOn(const std::vector<bool>& v);
628     MEDCOUPLING_EXPORT static DataArrayInt *BuildListOfSwitchedOff(const std::vector<bool>& v);
629     MEDCOUPLING_EXPORT static void PutIntoToSkylineFrmt(const std::vector< std::vector<int> >& v, DataArrayInt *& data, DataArrayInt *& dataIndex);
630     MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const;
631     MEDCOUPLING_EXPORT DataArrayInt *buildSubstraction(const DataArrayInt *other) const;
632     MEDCOUPLING_EXPORT DataArrayInt *buildSubstractionOptimized(const DataArrayInt *other) const;
633     MEDCOUPLING_EXPORT DataArrayInt *buildUnion(const DataArrayInt *other) const;
634     MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const;
635     MEDCOUPLING_EXPORT DataArrayInt *buildUnique() const;
636     MEDCOUPLING_EXPORT DataArrayInt *buildUniqueNotSorted() const;
637     MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const;
638     MEDCOUPLING_EXPORT void computeOffsets();
639     MEDCOUPLING_EXPORT void computeOffsetsFull();
640     MEDCOUPLING_EXPORT void findIdsRangesInListOfIds(const DataArrayInt *listOfIds, DataArrayInt *& rangeIdsFetched, DataArrayInt *& idsInInputListThatFetch) const;
641     MEDCOUPLING_EXPORT DataArrayInt *buildExplicitArrByRanges(const DataArrayInt *offsets) const;
642     MEDCOUPLING_EXPORT DataArrayInt *buildExplicitArrOfSliceOnScaledArr(int begin, int stop, int step) const;
643     MEDCOUPLING_EXPORT DataArrayInt *findRangeIdForEachTuple(const DataArrayInt *ranges) const;
644     MEDCOUPLING_EXPORT DataArrayInt *findIdInRangeForEachTuple(const DataArrayInt *ranges) const;
645     MEDCOUPLING_EXPORT void sortEachPairToMakeALinkedList();
646     MEDCOUPLING_EXPORT MCAuto<DataArrayInt> fromLinkedListOfPairToList() const;
647     MEDCOUPLING_EXPORT DataArrayInt *duplicateEachTupleNTimes(int nbTimes) const;
648     MEDCOUPLING_EXPORT DataArrayInt *getDifferentValues() const;
649     MEDCOUPLING_EXPORT std::vector<DataArrayInt *> partitionByDifferentValues(std::vector<int>& differentIds) const;
650     MEDCOUPLING_EXPORT std::vector< std::pair<int,int> > splitInBalancedSlices(int nbOfSlices) const;
651     template<class InputIterator>
652     void insertAtTheEnd(InputIterator first, InputIterator last);
653     MEDCOUPLING_EXPORT void aggregate(const DataArrayInt *other);
654     MEDCOUPLING_EXPORT void writeOnPlace(std::size_t id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
655     MEDCOUPLING_EXPORT static DataArrayInt *Add(const DataArrayInt *a1, const DataArrayInt *a2);
656     MEDCOUPLING_EXPORT void addEqual(const DataArrayInt *other);
657     MEDCOUPLING_EXPORT static DataArrayInt *Substract(const DataArrayInt *a1, const DataArrayInt *a2);
658     MEDCOUPLING_EXPORT void substractEqual(const DataArrayInt *other);
659     MEDCOUPLING_EXPORT static DataArrayInt *Multiply(const DataArrayInt *a1, const DataArrayInt *a2);
660     MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayInt *other);
661     MEDCOUPLING_EXPORT static DataArrayInt *Divide(const DataArrayInt *a1, const DataArrayInt *a2);
662     MEDCOUPLING_EXPORT void divideEqual(const DataArrayInt *other);
663     MEDCOUPLING_EXPORT static DataArrayInt *Modulus(const DataArrayInt *a1, const DataArrayInt *a2);
664     MEDCOUPLING_EXPORT void modulusEqual(const DataArrayInt *other);
665     MEDCOUPLING_EXPORT static DataArrayInt *Pow(const DataArrayInt *a1, const DataArrayInt *a2);
666     MEDCOUPLING_EXPORT void powEqual(const DataArrayInt *other);
667     MEDCOUPLING_EXPORT MemArray<int>& accessToMemArray() { return _mem; }
668     MEDCOUPLING_EXPORT const MemArray<int>& accessToMemArray() const { return _mem; }
669   public:
670     MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end);
671     MEDCOUPLING_EXPORT static DataArrayInt *Range(int begin, int end, int step);
672   public:
673     MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
674     MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
675     MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
676     MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
677   private:
678     template<class OP>
679     MCAuto<DataArrayInt> findIdsAdv(const OP& op) const;
680   private:
681     ~DataArrayInt() { }
682     DataArrayInt() { }
683   };
684
685   template<class OP>
686   MCAuto<DataArrayInt> DataArrayInt::findIdsAdv(const OP& op) const
687   {
688     checkAllocated();
689     if(getNumberOfComponents()!=1)
690       throw INTERP_KERNEL::Exception("DataArrayInt::findIdsAdv : this must have exactly one component !");
691     const int *cptr(getConstPointer());
692     MCAuto<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
693     int nbOfTuples(getNumberOfTuples());
694     for(int i=0;i<nbOfTuples;i++,cptr++)
695       if(op(*cptr))
696         ret->pushBackSilent(i);
697     return ret;
698   }
699
700   class DataArrayChar : public DataArrayTemplate<char>
701   {
702   public:
703     MEDCOUPLING_EXPORT virtual DataArrayChar *buildEmptySpecializedDAChar() const = 0;
704     MEDCOUPLING_EXPORT int getHashCode() const;
705     MEDCOUPLING_EXPORT bool isEqual(const DataArrayChar& other) const;
706     MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const;
707     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayChar& other) const;
708     MEDCOUPLING_EXPORT void fillWithZero();
709     MEDCOUPLING_EXPORT std::string repr() const;
710     MEDCOUPLING_EXPORT std::string reprZip() const;
711     MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const;
712     MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<char>::mySelectByTupleId(new2OldBg,new2OldEnd); }
713     MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const DataArrayInt& di) const { return DataArrayTemplate<char>::mySelectByTupleId(di); }
714     MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<char>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
715     MEDCOUPLING_EXPORT DataArrayChar *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<char>::myKeepSelectedComponents(compoIds); }
716     MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate<char>::mySelectByTupleIdSafeSlice(bg,end2,step); }
717     MEDCOUPLING_EXPORT bool isUniform(char val) const;
718     MEDCOUPLING_EXPORT void meldWith(const DataArrayChar *other);
719     MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<char>::mySelectByTupleRanges(ranges); }
720     MEDCOUPLING_EXPORT void getTuple(int tupleId, char *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
721     MEDCOUPLING_EXPORT DataArrayInt *findIdsEqual(char val) const;
722     MEDCOUPLING_EXPORT DataArrayInt *findIdsNotEqual(char val) const;
723     MEDCOUPLING_EXPORT int findIdSequence(const std::vector<char>& vals) const;
724     MEDCOUPLING_EXPORT int findIdFirstEqualTuple(const std::vector<char>& tupl) const;
725     MEDCOUPLING_EXPORT int findIdFirstEqual(char value) const;
726     MEDCOUPLING_EXPORT int findIdFirstEqual(const std::vector<char>& vals) const;
727     MEDCOUPLING_EXPORT bool presenceOfTuple(const std::vector<char>& tupl) const;
728     MEDCOUPLING_EXPORT bool presenceOfValue(char value) const;
729     MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector<char>& vals) const;
730     MEDCOUPLING_EXPORT DataArrayInt *findIdsInRange(char vmin, char vmax) const;
731     MEDCOUPLING_EXPORT static DataArrayChar *Aggregate(const DataArrayChar *a1, const DataArrayChar *a2);
732     MEDCOUPLING_EXPORT static DataArrayChar *Aggregate(const std::vector<const DataArrayChar *>& arr);
733     MEDCOUPLING_EXPORT static DataArrayChar *Meld(const DataArrayChar *a1, const DataArrayChar *a2);
734     MEDCOUPLING_EXPORT static DataArrayChar *Meld(const std::vector<const DataArrayChar *>& arr);
735     template<class InputIterator>
736     void insertAtTheEnd(InputIterator first, InputIterator last);
737     MEDCOUPLING_EXPORT MemArray<char>& accessToMemArray() { return _mem; }
738     MEDCOUPLING_EXPORT const MemArray<char>& accessToMemArray() const { return _mem; }
739   public:
740     //MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
741     //MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
742     //MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
743     //MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
744   protected:
745     DataArrayChar() { }
746   };
747
748   class DataArrayByteIterator;
749
750   class DataArrayByte : public DataArrayChar
751   {
752   public:
753     MEDCOUPLING_EXPORT static DataArrayByte *New();
754     MEDCOUPLING_EXPORT DataArrayChar *buildEmptySpecializedDAChar() const;
755     MEDCOUPLING_EXPORT DataArrayByteIterator *iterator();
756     MEDCOUPLING_EXPORT DataArrayByte *deepCopy() const;
757     MEDCOUPLING_EXPORT DataArrayByte *performCopyOrIncrRef(bool deepCopy) const;
758     MEDCOUPLING_EXPORT DataArrayByte *buildNewEmptyInstance() const { return DataArrayByte::New(); }
759     MEDCOUPLING_EXPORT char byteValue() const;
760     MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
761     MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
762     MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
763     MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
764     MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
765     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
766     MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
767     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const;
768     MEDCOUPLING_EXPORT std::vector<bool> toVectorOfBool() const;
769   private:
770     ~DataArrayByte() { }
771     DataArrayByte() { }
772   };
773
774   class DataArrayAsciiCharIterator;
775
776   class DataArrayAsciiChar : public DataArrayChar
777   {
778   public:
779     MEDCOUPLING_EXPORT static DataArrayAsciiChar *New();
780     MEDCOUPLING_EXPORT static DataArrayAsciiChar *New(const std::string& st);
781     MEDCOUPLING_EXPORT static DataArrayAsciiChar *New(const std::vector<std::string>& vst, char defaultChar);
782     MEDCOUPLING_EXPORT DataArrayChar *buildEmptySpecializedDAChar() const;
783     MEDCOUPLING_EXPORT DataArrayAsciiCharIterator *iterator();
784     MEDCOUPLING_EXPORT DataArrayAsciiChar *deepCopy() const;
785     MEDCOUPLING_EXPORT DataArrayAsciiChar *performCopyOrIncrRef(bool deepCopy) const;
786     MEDCOUPLING_EXPORT DataArrayAsciiChar *buildNewEmptyInstance() const { return DataArrayAsciiChar::New(); }
787     MEDCOUPLING_EXPORT char asciiCharValue() const;
788     MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
789     MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
790     MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
791     MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
792     MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
793     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
794     MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
795     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const;
796   private:
797     ~DataArrayAsciiChar() { }
798     DataArrayAsciiChar() { }
799     DataArrayAsciiChar(const std::string& st);
800     DataArrayAsciiChar(const std::vector<std::string>& vst, char defaultChar);
801   };
802
803   template<class T>
804   class DataArrayIterator
805   {
806   public:
807     DataArrayIterator(typename Traits<T>::ArrayType *da);
808     ~DataArrayIterator();
809     MEDCOUPLING_EXPORT typename Traits<T>::ArrayTuple *nextt();
810   private:
811     typename Traits<T>::ArrayType *_da;
812     T *_pt;
813     int _tuple_id;
814     int _nb_comp;
815     int _nb_tuple;
816   };
817
818   template<class T>
819   class DataArrayTuple
820   {
821   public:
822     MEDCOUPLING_EXPORT DataArrayTuple(T *pt, int nbOfComp);
823     MEDCOUPLING_EXPORT std::string repr() const;
824     MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
825     MEDCOUPLING_EXPORT const T *getConstPointer() const { return  _pt; }
826     MEDCOUPLING_EXPORT T *getPointer() { return _pt; }
827     MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *buildDA(int nbOfTuples, int nbOfCompo) const;
828   protected:
829     T zeValue() const;
830   protected:
831     T *_pt;
832     int _nb_of_compo;
833   };
834
835   class DataArrayDoubleTuple;
836
837   class DataArrayDoubleIterator : public DataArrayIterator<double>
838   {
839   public:
840     MEDCOUPLING_EXPORT DataArrayDoubleIterator(DataArrayDouble *da);
841     MEDCOUPLING_EXPORT ~DataArrayDoubleIterator() { }
842   };
843
844   class DataArrayDoubleTuple : public DataArrayTuple<double>
845   {
846   public:
847     MEDCOUPLING_EXPORT DataArrayDoubleTuple(double *pt, int nbOfComp);
848     MEDCOUPLING_EXPORT std::string repr() const;
849     MEDCOUPLING_EXPORT double doubleValue() const;
850     MEDCOUPLING_EXPORT DataArrayDouble *buildDADouble(int nbOfTuples, int nbOfCompo) const;
851   };
852
853   class DataArrayFloatTuple;
854
855   class DataArrayFloatIterator : public DataArrayIterator<float>
856   {
857   public:
858     MEDCOUPLING_EXPORT DataArrayFloatIterator(DataArrayFloat *da);
859     MEDCOUPLING_EXPORT ~DataArrayFloatIterator() { }
860   };
861
862   class DataArrayFloatTuple : public DataArrayTuple<float>
863   {
864   public:
865     MEDCOUPLING_EXPORT DataArrayFloatTuple(float *pt, int nbOfComp);
866     MEDCOUPLING_EXPORT std::string repr() const;
867     MEDCOUPLING_EXPORT float floatValue() const;
868     MEDCOUPLING_EXPORT DataArrayFloat *buildDAFloat(int nbOfTuples, int nbOfCompo) const;
869   };
870   
871   class DataArrayIntTuple;
872
873   class DataArrayIntIterator : public DataArrayIterator<int>
874   {
875   public:
876     MEDCOUPLING_EXPORT DataArrayIntIterator(DataArrayInt *da);
877     MEDCOUPLING_EXPORT ~DataArrayIntIterator() { }
878   };
879
880   class DataArrayIntTuple : public DataArrayTuple<int>
881   {
882   public:
883     MEDCOUPLING_EXPORT DataArrayIntTuple(int *pt, int nbOfComp);
884     MEDCOUPLING_EXPORT std::string repr() const;
885     MEDCOUPLING_EXPORT int intValue() const;
886     MEDCOUPLING_EXPORT DataArrayInt *buildDAInt(int nbOfTuples, int nbOfCompo) const;
887   };
888
889   class DataArrayAsciiCharTuple;
890
891   class DataArrayAsciiCharIterator
892   {
893   public:
894     MEDCOUPLING_EXPORT DataArrayAsciiCharIterator(DataArrayAsciiChar *da);
895     MEDCOUPLING_EXPORT ~DataArrayAsciiCharIterator();
896     MEDCOUPLING_EXPORT DataArrayAsciiCharTuple *nextt();
897   private:
898     DataArrayAsciiChar *_da;
899     char *_pt;
900     int _tuple_id;
901     int _nb_comp;
902     int _nb_tuple;
903   };
904
905   class DataArrayAsciiCharTuple
906   {
907   public:
908     MEDCOUPLING_EXPORT DataArrayAsciiCharTuple(char *pt, int nbOfComp);
909     MEDCOUPLING_EXPORT std::string repr() const;
910     MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
911     MEDCOUPLING_EXPORT const char *getConstPointer() const { return  _pt; }
912     MEDCOUPLING_EXPORT char *getPointer() { return _pt; }
913     MEDCOUPLING_EXPORT char asciiCharValue() const;
914     MEDCOUPLING_EXPORT DataArrayAsciiChar *buildDAAsciiChar(int nbOfTuples, int nbOfCompo) const;
915   private:
916     char *_pt;
917     int _nb_of_compo;
918   };
919   
920   class DataArrayByteTuple;
921
922   class DataArrayByteIterator
923   {
924   public:
925     MEDCOUPLING_EXPORT DataArrayByteIterator(DataArrayByte *da);
926     MEDCOUPLING_EXPORT ~DataArrayByteIterator();
927     MEDCOUPLING_EXPORT DataArrayByteTuple *nextt();
928   private:
929     DataArrayByte *_da;
930     char *_pt;
931     int _tuple_id;
932     int _nb_comp;
933     int _nb_tuple;
934   };
935
936   class DataArrayByteTuple
937   {
938   public:
939     MEDCOUPLING_EXPORT DataArrayByteTuple(char *pt, int nbOfComp);
940     MEDCOUPLING_EXPORT std::string repr() const;
941     MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; }
942     MEDCOUPLING_EXPORT const char *getConstPointer() const { return  _pt; }
943     MEDCOUPLING_EXPORT char *getPointer() { return _pt; }
944     MEDCOUPLING_EXPORT char byteValue() const;
945     MEDCOUPLING_EXPORT DataArrayByte *buildDAByte(int nbOfTuples, int nbOfCompo) const;
946   private:
947     char *_pt;
948     int _nb_of_compo;
949   };
950 }
951
952 namespace MEDCoupling
953 {
954   template<class T>
955   template<class InputIterator>
956   void MemArray<T>::insertAtTheEnd(InputIterator first, InputIterator last)
957   {
958     T *pointer=_pointer.getPointer();
959     while(first!=last)
960       {
961         if(_nb_of_elem>=_nb_of_elem_alloc)
962           {
963             reserve(_nb_of_elem_alloc>0?2*_nb_of_elem_alloc:1);
964             pointer=_pointer.getPointer();
965           }
966         pointer[_nb_of_elem++]=*first++;
967       }
968   }
969   
970   template<class InputIterator>
971   void DataArrayDouble::insertAtTheEnd(InputIterator first, InputIterator last)
972   {
973     int nbCompo(getNumberOfComponents());
974     if(nbCompo==1)
975       _mem.insertAtTheEnd(first,last);
976     else if(nbCompo==0)
977       {
978         _info_on_compo.resize(1);
979         _mem.insertAtTheEnd(first,last);
980       }
981     else
982       throw INTERP_KERNEL::Exception("DataArrayDouble::insertAtTheEnd : not available for DataArrayDouble with number of components different than 1 !");
983   }
984
985   template<class InputIterator>
986   void DataArrayInt::insertAtTheEnd(InputIterator first, InputIterator last)
987   {
988     int nbCompo(getNumberOfComponents());
989     if(nbCompo==1)
990       _mem.insertAtTheEnd(first,last);
991     else if(nbCompo==0)
992       {
993         _info_on_compo.resize(1);
994         _mem.insertAtTheEnd(first,last);
995       }
996     else
997       throw INTERP_KERNEL::Exception("DataArrayInt::insertAtTheEnd : not available for DataArrayInt with number of components different than 1 !");
998   }
999
1000   template<class InputIterator>
1001   void DataArrayChar::insertAtTheEnd(InputIterator first, InputIterator last)
1002   {
1003     int nbCompo(getNumberOfComponents());
1004     if(nbCompo==1)
1005       _mem.insertAtTheEnd(first,last);
1006     else if(nbCompo==0)
1007       {
1008         _info_on_compo.resize(1);
1009         _mem.insertAtTheEnd(first,last);
1010       }
1011     else
1012       throw INTERP_KERNEL::Exception("DataArrayChar::insertAtTheEnd : not available for DataArrayChar with number of components different than 1 !");
1013   }
1014 }
1015
1016 #endif