Skip to content
Snippets Groups Projects
Commit 3bd901a5 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber Committed by Jakub Klinkovský
Browse files

Added method containsValue to List.

parent 6b7abdc2
No related branches found
No related tags found
1 merge request!20Traversers optimizations
......@@ -109,6 +109,13 @@ template< class T > class List
template< typename Array >
void toArray( Array& array );
/***
* \brief Checks if there is an element with value \e v in given array.
*
* \param v Reference to a value.
*/
bool containsValue( const T& v ) const;
/// Erases data element at given position.
///
/// \param ind Index of the data element one chooses to remove.
......@@ -146,7 +153,7 @@ template< class T > class List
///
/// \param file Name of file.
bool DeepLoad( File& file );
protected:
/// Pointer to the first element.
ListDataElement< T >* first;
......
......@@ -207,6 +207,14 @@ void List< T >::toArray( Array& array )
for( int i = 0; i < this->getSize(); i++ )
array[ i ] = ( *this )[ i ];
}
template< typename T >
bool List< T >::containsValue( const T& v ) const
{
for( int i = 0; i < this->getSize(); i++ )
if( ( *this )[ i ] == v )
return true;
return false;
}
template< typename T >
void List< T >::Erase( const int& ind )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment