return new DataArrayIntIterator(this);
}
-/*!
- * Creates a new DataArrayInt containing IDs (indices) of tuples holding value equal to a
- * given one. The ids are sorted in the ascending order.
- * \param [in] val - the value to find within \a this.
- * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
- * array using decrRef() as it is no more needed.
- * \throw If \a this is not allocated.
- * \throw If \a this->getNumberOfComponents() != 1.
- * \sa DataArrayInt::findIdsEqualTuple
- */
-DataArrayIdType *DataArrayInt::findIdsEqual(int val) const
-{
- checkAllocated();
- if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::findIdsEqual : the array must have only one component, you can call 'rearrange' method before !");
- const int *cptr(getConstPointer());
- MCAuto<DataArrayIdType> ret(DataArrayIdType::New()); ret->alloc(0,1);
- std::size_t nbOfTuples(getNumberOfTuples());
- for(std::size_t i=0;i<nbOfTuples;i++,cptr++)
- if(*cptr==val)
- ret->pushBackSilent(ToIdType(i));
- return ret.retn();
-}
-
/*!
* Creates a new DataArrayInt containing IDs (indices) of tuples holding value \b not
* equal to a given one.
MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const;
MEDCOUPLING_EXPORT void transformWithIndArr(const T *indArrBg, const T *indArrEnd);
MEDCOUPLING_EXPORT void transformWithIndArr(const MapKeyVal<T>& m);
+ MEDCOUPLING_EXPORT DataArrayIdType *findIdsEqual(T val) const;
protected:
template<class ALG>
void switchOnTupleAlg(T val, std::vector<bool>& vec, ALG algo) const;
MEDCOUPLING_EXPORT bool hasUniqueValues() const;
MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt32 *a, const std::vector<int>& compoIds);
MEDCOUPLING_EXPORT DataArrayInt32Iterator *iterator();
- MEDCOUPLING_EXPORT DataArrayIdType *findIdsEqual(int val) const;
MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotEqual(int val) const;
MEDCOUPLING_EXPORT DataArrayInt32 *findIdsEqualList(const int *valsBg, const int *valsEnd) const;
MEDCOUPLING_EXPORT DataArrayInt32 *findIdsNotEqualList(const int *valsBg, const int *valsEnd) const;
this->declareAsNew();
}
+ /*!
+ * Creates a new DataArrayInt containing IDs (indices) of tuples holding value equal to a
+ * given one. The ids are sorted in the ascending order.
+ * \param [in] val - the value to find within \a this.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \sa DataArrayInt::findIdsEqualTuple
+ */
+ template<class T>
+ DataArrayIdType *DataArrayDiscrete<T>::findIdsEqual(T val) const
+ {
+ this->checkAllocated();
+ if(this->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::findIdsEqual : the array must have only one component, you can call 'rearrange' method before !");
+ const T *cptr(this->getConstPointer());
+ MCAuto<DataArrayIdType> ret(DataArrayIdType::New()); ret->alloc(0,1);
+ std::size_t nbOfTuples(this->getNumberOfTuples());
+ for(std::size_t i=0;i<nbOfTuples;i++,cptr++)
+ if(*cptr==val)
+ ret->pushBackSilent(ToIdType(i));
+ return ret.retn();
+ }
+
////////////////////////////////////
/*!