S
sks_cpp
I am somewhat new to STL and the plethora of library functions they have. I
looked at sgi's stl info. and I was overwhelmed so I thought I would present
my question here.
I have
std::map<WWN*, Drive*> m_Drives
I want to take that and run a functor through all of them (the functor has
Drive* has the parameter type) and whichever ones meet the predicate functor
will need to be added to a list of Drive*s. (std::list<Drive*> driveList)
I can write a loop to do this and in fact, I will do it here to show what I
am trying to achieve. But I would rather use the library functions, if
possible.
for ( mapIter i = m_Drives.begin(); i != m_Drives.end(); ++i )
{
if ( i.second->getType == someType && i.second->getCapacity >=
someCapacity )
driveList.push_back(i.second);
}
My code may not compile since I just wrote it on the fly.
My for loop is only few lines long so maybe doing that is better than using
the standard library functions.
However, I read part of Scott Meyers's Effective STL stuff and he says that
standard functions are efficient, correct, and maintainable. Anyway, any
help would be nice.
Thanks.
looked at sgi's stl info. and I was overwhelmed so I thought I would present
my question here.
I have
std::map<WWN*, Drive*> m_Drives
I want to take that and run a functor through all of them (the functor has
Drive* has the parameter type) and whichever ones meet the predicate functor
will need to be added to a list of Drive*s. (std::list<Drive*> driveList)
I can write a loop to do this and in fact, I will do it here to show what I
am trying to achieve. But I would rather use the library functions, if
possible.
for ( mapIter i = m_Drives.begin(); i != m_Drives.end(); ++i )
{
if ( i.second->getType == someType && i.second->getCapacity >=
someCapacity )
driveList.push_back(i.second);
}
My code may not compile since I just wrote it on the fly.
My for loop is only few lines long so maybe doing that is better than using
the standard library functions.
However, I read part of Scott Meyers's Effective STL stuff and he says that
standard functions are efficient, correct, and maintainable. Anyway, any
help would be nice.
Thanks.