Added count

p4#: 21239
This commit is contained in:
Magne Sjaastad 2013-04-11 12:00:06 +02:00
parent db1dd5dd0d
commit 9ae4ac94b6
2 changed files with 21 additions and 0 deletions

View File

@ -213,6 +213,7 @@ public:
void set(size_t index, DataType* pointer);
void insert(size_t indexAfter, DataType* pointer);
void insert(size_t indexAfter, const std::vector<PdmPointer<DataType> >& objects);
size_t count(const DataType* pointer) const;
void clear();
void erase(size_t index);

View File

@ -482,6 +482,26 @@ void PdmPointersField<DataType*>::insert(size_t indexAfter, const std::vector<Pd
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename DataType>
size_t PdmPointersField<DataType*>::count(const DataType* pointer) const
{
size_t itemCount = 0;
typename std::vector< PdmPointer< DataType > >::const_iterator it;
for (it = m_pointers.begin(); it != m_pointers.end(); ++it)
{
if (*it == pointer)
{
itemCount++;
}
}
return itemCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------