From fa4f47719034e5cc6283f84771467644a91ae46a Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 20 Dec 2018 08:09:10 +0100 Subject: [PATCH] Example of move of a simple method getHashCode from DataArrayInt -> DataArrayDiscrete --- src/MEDCoupling/MEDCouplingMemArray.cxx | 21 --------------------- src/MEDCoupling/MEDCouplingMemArray.hxx | 2 +- src/MEDCoupling/MEDCouplingMemArray.txx | 22 ++++++++++++++++++++++ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index cbf0576d3..5651e374a 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -3699,27 +3699,6 @@ int DataArrayInt::intValue() const throw INTERP_KERNEL::Exception("DataArrayInt::intValue : DataArrayInt instance is not allocated !"); } -/*! - * Returns an integer value characterizing \a this array, which is useful for a quick - * comparison of many instances of DataArrayInt. - * \return int - the hash value. - * \throw If \a this is not allocated. - */ -int DataArrayInt::getHashCode() const -{ - checkAllocated(); - std::size_t nbOfElems=getNbOfElems(); - int ret=nbOfElems*65536; - int delta=3; - if(nbOfElems>48) - delta=nbOfElems/8; - int ret0=0; - const int *pt=begin(); - for(std::size_t i=0;i void switchOnTupleAlg(T val, std::vector& vec, ALG algo) const; @@ -564,7 +565,6 @@ namespace MEDCoupling friend class DataArrayDiscrete; public: MEDCOUPLING_EXPORT int intValue() const; - MEDCOUPLING_EXPORT int getHashCode() const; MEDCOUPLING_EXPORT DataArrayInt32 *deepCopy() const;//ok MEDCOUPLING_EXPORT DataArrayInt32 *buildNewEmptyInstance() const { return DataArrayInt32::New(); }//ok MEDCOUPLING_EXPORT std::string repr() const; diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index a9d0a697a..7f6731e94 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -3730,6 +3730,28 @@ struct NotInRange } } + /*! + * Returns an integer value characterizing \a this array, which is useful for a quick + * comparison of many instances of DataArrayInt. + * \return int - the hash value. + * \throw If \a this is not allocated. + */ + template + int DataArrayDiscrete::getHashCode() const + { + DataArrayTemplate::checkAllocated(); + std::size_t nbOfElems(DataArrayTemplate::getNbOfElems()); + int ret=nbOfElems*65536; + int delta=3; + if(nbOfElems>48) + delta=nbOfElems/8; + T ret0(0); + const T *pt(DataArrayTemplate::begin()); + for(std::size_t i=0;i