From: Anthony Geay Date: Fri, 26 May 2017 21:26:07 +0000 (+0200) Subject: On the road X-Git-Tag: V8_4_0a1~34 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fagy%2FTemplate1;p=tools%2Fmedcoupling.git On the road --- 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()); } /*!