template class MEDCoupling::DataArrayIterator<int>;
template class MEDCoupling::DataArrayDiscrete<Int32>;
template class MEDCoupling::DataArrayDiscreteSigned<Int32>;
+template class MEDCoupling::DataArrayDiscrete<Int64>;
+template class MEDCoupling::DataArrayDiscreteSigned<Int64>;
template class MEDCoupling::DataArrayTuple<int>;
template class MEDCoupling::DataArrayTuple<double>;
template class MEDCoupling::DataArrayTuple<float>;
stream << "DataArrayDouble C++ instance at " << this << ". ";
if(isAllocated())
{
- int nbOfCompo=(int)_info_on_compo.size();
+ std::size_t nbOfCompo(_info_on_compo.size());
if(nbOfCompo>=1)
{
- int nbOfTuples=getNumberOfTuples();
+ std::size_t nbOfTuples(getNumberOfTuples());
stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl;
reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR);
}
ofs << std::endl << idt << "</DataArray>\n";
}
-void DataArrayInt::reprCppStream(const std::string& varName, std::ostream& stream) const
-{
- int nbTuples=getNumberOfTuples(),nbComp=getNumberOfComponents();
- const int *data=getConstPointer();
- stream << "DataArrayInt *" << varName << "=DataArrayInt::New();" << std::endl;
- if(nbTuples*nbComp>=1)
- {
- stream << "const int " << varName << "Data[" << nbTuples*nbComp << "]={";
- std::copy(data,data+nbTuples*nbComp-1,std::ostream_iterator<int>(stream,","));
- stream << data[nbTuples*nbComp-1] << "};" << std::endl;
- stream << varName << "->useArray(" << varName << "Data,false,CPP_DEALLOC," << nbTuples << "," << nbComp << ");" << std::endl;
- }
- else
- stream << varName << "->alloc(" << nbTuples << "," << nbComp << ");" << std::endl;
- stream << varName << "->setName(\"" << getName() << "\");" << std::endl;
-}
-
-/*!
- * Method that gives a quick overvien of \a this for python.
- */
-void DataArrayInt::reprQuickOverview(std::ostream& stream) const
-{
- static const std::size_t MAX_NB_OF_BYTE_IN_REPR=300;
- stream << "DataArrayInt C++ instance at " << this << ". ";
- if(isAllocated())
- {
- int nbOfCompo=(int)_info_on_compo.size();
- if(nbOfCompo>=1)
- {
- int nbOfTuples=getNumberOfTuples();
- stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl;
- reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR);
- }
- else
- stream << "Number of components : 0.";
- }
- else
- stream << "*** No data allocated ****";
-}
-
-void DataArrayInt::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const
-{
- const int *data=begin();
- int nbOfTuples=getNumberOfTuples();
- int nbOfCompo=(int)_info_on_compo.size();
- std::ostringstream oss2; oss2 << "[";
- std::string oss2Str(oss2.str());
- bool isFinished=true;
- for(int i=0;i<nbOfTuples && isFinished;i++)
- {
- if(nbOfCompo>1)
- {
- oss2 << "(";
- for(int j=0;j<nbOfCompo;j++,data++)
- {
- oss2 << *data;
- if(j!=nbOfCompo-1) oss2 << ", ";
- }
- oss2 << ")";
- }
- else
- oss2 << *data++;
- if(i!=nbOfTuples-1) oss2 << ", ";
- std::string oss3Str(oss2.str());
- if(oss3Str.length()<maxNbOfByteInRepr)
- oss2Str=oss3Str;
- else
- isFinished=false;
- }
- stream << oss2Str;
- if(!isFinished)
- stream << "... ";
- stream << "]";
-}
-
/*!
* Computes distribution of values of \a this one-dimensional array between given value
* ranges (casts). This method is typically useful for entity number splitting by types,
{
return this->buildDA(nbOfTuples,nbOfCompo);
}
+
+DataArrayInt64 *DataArrayInt64::deepCopy() const
+{
+ return new DataArrayInt64(*this);
+}
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(); }
MEDCOUPLING_EXPORT void pack() const;
- MEDCOUPLING_EXPORT bool isAllocated() const;
+ MEDCOUPLING_EXPORT bool isAllocated() const override;
MEDCOUPLING_EXPORT void checkAllocated() const;
MEDCOUPLING_EXPORT void desallocate();
MEDCOUPLING_EXPORT void reserve(std::size_t nbOfElems);
MEDCOUPLING_EXPORT int getHashCode() const;
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT std::string reprZip() const;
+ MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
protected:
template<class ALG>
void switchOnTupleAlg(T val, std::vector<bool>& vec, ALG algo) const;
MEDCOUPLING_EXPORT DataArrayInt32 *deepCopy() const;//ok
MEDCOUPLING_EXPORT DataArrayInt32 *buildNewEmptyInstance() const { return DataArrayInt32::New(); }//ok
MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const;
- MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd);
MEDCOUPLING_EXPORT void transformWithIndArr(const MapKeyVal<int>& m);
MEDCOUPLING_EXPORT DataArrayInt32 *transformWithIndArrR(const int *indArr2Bg, const int *indArrEnd) const;
class DataArrayInt64 : public DataArrayDiscrete<Int64>
{
friend class DataArrayDiscrete<Int64>;
+ public:
+ MEDCOUPLING_EXPORT DataArrayInt64 *deepCopy() const;
+ MEDCOUPLING_EXPORT DataArrayInt64 *buildNewEmptyInstance() const { return DataArrayInt64::New(); }//ok
+ MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<Int64>::mySelectByTupleId(new2OldBg,new2OldEnd); }
+ MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleId(const DataArrayInt32& di) const { return DataArrayTemplate<Int64>::mySelectByTupleId(di); }
+ MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<Int64>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
+ MEDCOUPLING_EXPORT DataArrayInt64 *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<Int64>::myKeepSelectedComponents(compoIds); }
+ MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate<Int64>::mySelectByTupleIdSafeSlice(bg,end2,step); }
+ MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<Int64>::mySelectByTupleRanges(ranges); }
private:
~DataArrayInt64() { }
DataArrayInt64() { }
template<class T>
typename Traits<T>::ArrayType *DataArrayDiscrete<T>::New()
{
- return new typename Traits<T>::ArrayType;
+ return nullptr;//new typename Traits<T>::ArrayType;
}
/*!
template<class T>
bool DataArrayDiscrete<T>::isEqualWithoutConsideringStrAndOrder(const typename Traits<T>::ArrayType& other) const
{
- MCAuto<DataArrayInt> a(static_cast<const typename Traits<T>::ArrayType *>(this)->deepCopy()),b(other.deepCopy());
+ MCAuto<typename Traits<T>::ArrayType> a((static_cast<const typename Traits<T>::ArrayType *>(this))->deepCopy());
+ MCAuto<typename Traits<T>::ArrayType> b((static_cast<const typename Traits<T>::ArrayType *>(&other))->deepCopy());
a->sort();
b->sort();
return a->isEqualWithoutConsideringStr(*b);
const T *thisPt(this->begin()),*pt(partOfThis.begin());
MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
ret->alloc(nbTuples,1);
- T *retPt(ret->getPointer());
+ mcIdType *retPt(ret->getPointer());
std::map<int,mcIdType> m;
for(std::size_t i=0;i<thisNbTuples;i++,thisPt++)
m[*thisPt]=(mcIdType)i;
return ret.str();
}
+ template<class T>
+ void DataArrayDiscrete<T>::reprCppStream(const std::string& varName, std::ostream& stream) const
+ {
+ std::size_t nbTuples(DataArrayTemplate<T>::getNumberOfTuples()),nbComp(DataArray::getNumberOfComponents());
+ const T *data(DataArrayTemplate<T>::getConstPointer());
+ stream << Traits<T>::ArrayTypeName << " *" << varName << "=" << Traits<T>::ArrayTypeName << "::New();" << std::endl;
+ if(nbTuples*nbComp>=1)
+ {
+ stream << "const int " << varName << "Data[" << nbTuples*nbComp << "]={";
+ std::copy(data,data+nbTuples*nbComp-1,std::ostream_iterator<int>(stream,","));
+ stream << data[nbTuples*nbComp-1] << "};" << std::endl;
+ stream << varName << "->useArray(" << varName << "Data,false,CPP_DEALLOC," << nbTuples << "," << nbComp << ");" << std::endl;
+ }
+ else
+ stream << varName << "->alloc(" << nbTuples << "," << nbComp << ");" << std::endl;
+ stream << varName << "->setName(\"" << DataArray::getName() << "\");" << std::endl;
+ }
+
+ /*!
+ * Method that gives a quick overvien of \a this for python.
+ */
+ template<class T>
+ void DataArrayDiscrete<T>::reprQuickOverview(std::ostream& stream) const
+ {
+ static const std::size_t MAX_NB_OF_BYTE_IN_REPR=300;
+ stream << Traits<T>::ArrayTypeName << " C++ instance at " << this << ". ";
+ if(DataArrayTemplate<T>::isAllocated())
+ {
+ std::size_t nbOfCompo(DataArray::getNumberOfComponents());
+ if(nbOfCompo>=1)
+ {
+ std::size_t nbOfTuples(DataArrayTemplate<T>::getNumberOfTuples());
+ stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl;
+ reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR);
+ }
+ else
+ stream << "Number of components : 0.";
+ }
+ else
+ stream << "*** No data allocated ****";
+ }
+
+ template<class T>
+ void DataArrayDiscrete<T>::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const
+ {
+ const T *data(DataArrayTemplate<T>::begin());
+ std::size_t nbOfTuples(DataArrayTemplate<T>::getNumberOfTuples()),nbOfCompo(DataArray::getNumberOfComponents());
+ std::ostringstream oss2; oss2 << "[";
+ std::string oss2Str(oss2.str());
+ bool isFinished=true;
+ for(int i=0;i<nbOfTuples && isFinished;i++)
+ {
+ if(nbOfCompo>1)
+ {
+ oss2 << "(";
+ for(int j=0;j<nbOfCompo;j++,data++)
+ {
+ oss2 << *data;
+ if(j!=nbOfCompo-1) oss2 << ", ";
+ }
+ oss2 << ")";
+ }
+ else
+ oss2 << *data++;
+ if(i!=nbOfTuples-1) oss2 << ", ";
+ std::string oss3Str(oss2.str());
+ if(oss3Str.length()<maxNbOfByteInRepr)
+ oss2Str=oss3Str;
+ else
+ isFinished=false;
+ }
+ stream << oss2Str;
+ if(!isFinished)
+ stream << "... ";
+ stream << "]";
+ }
+
////////////////////////////////////
/*!