From 701d88fad1d61dd1f3d3707159f9aae8291919e1 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 31 Jan 2019 15:15:56 +0100 Subject: [PATCH] Prepare int64 management - example 3 --- src/MEDCoupling/MEDCouplingMemArray.cxx | 24 ------------------------ src/MEDCoupling/MEDCouplingMemArray.hxx | 2 +- src/MEDCoupling/MEDCouplingMemArray.txx | 25 +++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 714f8d34f..adfcaab7c 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -4440,30 +4440,6 @@ DataArrayIntIterator *DataArrayInt::iterator() return new DataArrayIntIterator(this); } -/*! - * Creates a new DataArrayInt containing IDs (indices) of tuples holding value equal to a - * given one. The ids are sorted in the ascending order. - * \param [in] val - the value to find within \a this. - * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this - * array using decrRef() as it is no more needed. - * \throw If \a this is not allocated. - * \throw If \a this->getNumberOfComponents() != 1. - * \sa DataArrayInt::findIdsEqualTuple - */ -DataArrayIdType *DataArrayInt::findIdsEqual(int val) const -{ - checkAllocated(); - if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayInt::findIdsEqual : the array must have only one component, you can call 'rearrange' method before !"); - const int *cptr(getConstPointer()); - MCAuto ret(DataArrayIdType::New()); ret->alloc(0,1); - std::size_t nbOfTuples(getNumberOfTuples()); - for(std::size_t i=0;ipushBackSilent(ToIdType(i)); - return ret.retn(); -} - /*! * Creates a new DataArrayInt containing IDs (indices) of tuples holding value \b not * equal to a given one. diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index f1a8fe036..ba0bc6ee5 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -548,6 +548,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const; MEDCOUPLING_EXPORT void transformWithIndArr(const T *indArrBg, const T *indArrEnd); MEDCOUPLING_EXPORT void transformWithIndArr(const MapKeyVal& m); + MEDCOUPLING_EXPORT DataArrayIdType *findIdsEqual(T val) const; protected: template void switchOnTupleAlg(T val, std::vector& vec, ALG algo) const; @@ -599,7 +600,6 @@ namespace MEDCoupling MEDCOUPLING_EXPORT bool hasUniqueValues() const; MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt32 *a, const std::vector& compoIds); MEDCOUPLING_EXPORT DataArrayInt32Iterator *iterator(); - MEDCOUPLING_EXPORT DataArrayIdType *findIdsEqual(int val) const; MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotEqual(int val) const; MEDCOUPLING_EXPORT DataArrayInt32 *findIdsEqualList(const int *valsBg, const int *valsEnd) const; MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotEqualList(const int *valsBg, const int *valsEnd) const; diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index c8ea9370f..ad70e7092 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -3956,6 +3956,31 @@ struct NotInRange this->declareAsNew(); } + /*! + * Creates a new DataArrayInt containing IDs (indices) of tuples holding value equal to a + * given one. The ids are sorted in the ascending order. + * \param [in] val - the value to find within \a this. + * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this + * array using decrRef() as it is no more needed. + * \throw If \a this is not allocated. + * \throw If \a this->getNumberOfComponents() != 1. + * \sa DataArrayInt::findIdsEqualTuple + */ + template + DataArrayIdType *DataArrayDiscrete::findIdsEqual(T val) const + { + this->checkAllocated(); + if(this->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::findIdsEqual : the array must have only one component, you can call 'rearrange' method before !"); + const T *cptr(this->getConstPointer()); + MCAuto ret(DataArrayIdType::New()); ret->alloc(0,1); + std::size_t nbOfTuples(this->getNumberOfTuples()); + for(std::size_t i=0;ipushBackSilent(ToIdType(i)); + return ret.retn(); + } + //////////////////////////////////// /*! -- 2.39.2