By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,796 Members | 1,205 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,796 IT Pros & Developers. It's quick & easy.

List<class> or list<Vector> access ?

P: n/a
Dear all,
I could not find the way to handle 'not normal' list objects, for example
using remove_if, find etc.

Example :
class Todo
{
public :
..
int getNumber(){ return num_;}
private:
int num_
}

int main(void)
{
list<Todolst_Todo;
...
// here comes the problem
lst_Todo.remove_if(???); // where num_ = x
}

The other constelation is: list<vector<vektor<int >

Have someone an idea who to talk with this objects ?

Many thanks.

brgds,
Birthe
Aug 14 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Birthe Gebhardt wrote:
Dear all,
I could not find the way to handle 'not normal' list objects, for example
using remove_if, find etc.

Example :
class Todo
{
public :
..
int getNumber(){ return num_;}
private:
int num_
}

int main(void)
{
list<Todolst_Todo;
...
// here comes the problem
lst_Todo.remove_if(???); // where num_ = x
}
You need a unary function or function object. Something like this:

class TodoEquals
{
public:
TodoEquals( int value ) : value( value ) {}
bool operator()( const Todo& td ) { return td.getNumber() == value; }

private:
int value;
};

Use as:

lst_Todo.remove_if( TodoEquals(x) );
The other constelation is: list<vector<vektor<int >
vector has no member function remove_if but you can use the template
function provided in <algorithmto do basically the same thing.
Have someone an idea who to talk with this objects ?

Many thanks.

brgds,
Birthe
Aug 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.