STL Predicate for searching a treeview columns



Started learning more and more about the STL, and found that it is really easy and convenient to use Predicate templates to search STL containers that are not indexed, like list and vector.

For example, if you have a vector of strings, the code ends up looking something like this:

// Predicate for searching a vector of strings
// Example use:
// iter = find_if( container.begin(), container.end(), StrListPred( s ) );
class StrListPred
{
  public:
	StrListPred( std::string x )	: id( x ) { }

	bool operator()( const std::string& o ) const
	{
		return o == id;
	}
  protected:
	const std::string			id;
};

Now, has anyone used this technique to search a TreeViewModel?  If so, could you please share your code?  (I want to get rid of all the ugly, non-STL like individual search loops if possible).

	Thanks in advance,
		Erik.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]