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<nbOfElems;i+=delta)
- ret0+=pt[i] & 0x1FFF;
- return ret+ret0;
-}
-
/*!
* Returns a full copy of \a this. For more info on copying data arrays see
* \ref MEDCouplingArrayBasicsCopyDeep.
MEDCOUPLING_EXPORT bool isMonotonic(bool increasing) const;
MEDCOUPLING_EXPORT void checkStrictlyMonotonic(bool increasing) const;
MEDCOUPLING_EXPORT bool isStrictlyMonotonic(bool increasing) const;
+ MEDCOUPLING_EXPORT int getHashCode() const;
protected:
template<class ALG>
void switchOnTupleAlg(T val, std::vector<bool>& vec, ALG algo) const;
friend class DataArrayDiscrete<Int32>;
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;
}
}
+ /*!
+ * 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<class T>
+ int DataArrayDiscrete<T>::getHashCode() const
+ {
+ DataArrayTemplate<T>::checkAllocated();
+ std::size_t nbOfElems(DataArrayTemplate<T>::getNbOfElems());
+ int ret=nbOfElems*65536;
+ int delta=3;
+ if(nbOfElems>48)
+ delta=nbOfElems/8;
+ T ret0(0);
+ const T *pt(DataArrayTemplate<T>::begin());
+ for(std::size_t i=0;i<nbOfElems;i+=delta)
+ ret0+=pt[i] & 0x1FFF;
+ return ret+ret0;
+ }
+
////////////////////////////////////
/*!