From f5abe7c84a2ee483df1fa0b68c672530b1a919a3 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 26 May 2017 23:26:07 +0200 Subject: [PATCH] On the road --- src/MEDCoupling/MEDCouplingMemArray.hxx | 3 ++ src/MEDCoupling/MEDCouplingMemArray.txx | 38 ++++++++++++------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 716bbb744..462cd5343 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -530,6 +530,9 @@ namespace MEDCoupling MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const typename Traits::ArrayType& other) const; MEDCOUPLING_EXPORT void switchOnTupleEqualTo(T val, std::vector& vec) const; MEDCOUPLING_EXPORT void switchOnTupleNotEqualTo(T val, std::vector& vec) const; + protected: + template + void switchOnTupleAlg(T val, std::vector& vec, ALG algo) const; protected: ~DataArrayDiscrete() { } }; diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index b66c6a667..aaec5ed8e 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -3307,16 +3307,10 @@ struct NotInRange b->sort(); return a->isEqualWithoutConsideringStr(*b); } - - /*! - * This method assumes that \a this has one component and is allocated. This method scans all tuples in \a this and for all tuple equal to \a val - * put True to the corresponding entry in \a vec. - * \a vec is expected to be with the same size than the number of tuples of \a this. - * - * \sa DataArrayInt::switchOnTupleNotEqualTo. - */ + template - void DataArrayDiscrete::switchOnTupleEqualTo(T val, std::vector& vec) const + template + void DataArrayDiscrete::switchOnTupleAlg(T val, std::vector& vec, ALG algo) const { this->checkAllocated(); if(this->getNumberOfComponents()!=1) @@ -3326,9 +3320,22 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::switchOnTupleEqualTo : number of tuples of this should be equal to size of input vector of bool !"); const T *pt(this->begin()); for(int i=0;i + void DataArrayDiscrete::switchOnTupleEqualTo(T val, std::vector& vec) const + { + switchOnTupleAlg(val,vec,std::equal_to()); + } /*! * This method assumes that \a this has one component and is allocated. This method scans all tuples in \a this and for all tuple different from \a val @@ -3340,16 +3347,7 @@ struct NotInRange template void DataArrayDiscrete::switchOnTupleNotEqualTo(T val, std::vector& vec) const { - this->checkAllocated(); - if(this->getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayInt::switchOnTupleNotEqualTo : number of components of this should be equal to one !"); - int nbOfTuples(this->getNumberOfTuples()); - if(nbOfTuples!=(int)vec.size()) - throw INTERP_KERNEL::Exception("DataArrayInt::switchOnTupleNotEqualTo : number of tuples of this should be equal to size of input vector of bool !"); - const T *pt(this->begin()); - for(int i=0;i()); } /*! -- 2.39.2