added Remove() and CountTypes() methods in COLLECTOR class
This commit is contained in:
parent
f0c913c65e
commit
da8e9e9bee
|
@ -129,6 +129,23 @@ public:
|
||||||
m_List.erase( m_List.begin() + aIndex );
|
m_List.erase( m_List.begin() + aIndex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function Remove
|
||||||
|
* removes the item aItem (if exists in the collector).
|
||||||
|
* @param aItem the item to be removed.
|
||||||
|
*/
|
||||||
|
void Remove( const EDA_ITEM *aItem )
|
||||||
|
{
|
||||||
|
for( size_t i = 0; i < m_List.size(); i++ )
|
||||||
|
{
|
||||||
|
if( m_List[i] == aItem )
|
||||||
|
{
|
||||||
|
m_List.erase( m_List.begin() + i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function operator[int]
|
* Function operator[int]
|
||||||
* is used for read only access and returns the object at \a aIndex.
|
* is used for read only access and returns the object at \a aIndex.
|
||||||
|
@ -223,6 +240,23 @@ public:
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Function CountType
|
||||||
|
* counts the number of items matching aType
|
||||||
|
* @param aType type we are interested in
|
||||||
|
* @return number of occurences
|
||||||
|
*/
|
||||||
|
int CountType( KICAD_T aType )
|
||||||
|
{
|
||||||
|
int cnt = 0;
|
||||||
|
for( size_t i = 0; i < m_List.size(); i++ )
|
||||||
|
{
|
||||||
|
if( m_List[i]->Type() == aType )
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Collect
|
* Function Collect
|
||||||
|
|
Loading…
Reference in New Issue