From: ageay Date: Fri, 4 May 2012 09:12:53 +0000 (+0000) Subject: Fast DataArrayInt hash code computation X-Git-Tag: V6_5_0~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=01a1fc3ee32b6afe5b19725daacb58c5937c10b6;p=tools%2Fmedcoupling.git Fast DataArrayInt hash code computation --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 4a3022687..76a475b4e 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -2909,6 +2909,24 @@ int DataArrayInt::intValue() const throw(INTERP_KERNEL::Exception) throw INTERP_KERNEL::Exception("DataArrayInt::intValue : DataArrayInt instance is not allocated !"); } +/*! + * This method expects that \b this is well allocated. If not an INTERP_KERNEL::Exception will be thrown. This method is useful for a quick comparison of many instances of DataArrayInt. + */ +int DataArrayInt::getHashCode() const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int nbOfElems=getNbOfElems(); + int ret=nbOfElems*65536; + int delta=3; + if(nbOfElems>48) + delta=nbOfElems/8; + int ret0=0; + const int *pt=begin(); + for(int i=0;i& info) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT int intValue() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT int getHashCode() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT bool empty() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *deepCpy() const; MEDCOUPLING_EXPORT DataArrayInt *performCpy(bool deepCpy) const;