|
Boost Users : |
Subject: Re: [Boost-users] algorithm question
From: Peter Foelsche (foelsche_at_[hidden])
Date: 2011-07-08 23:18:59
"Peter Foelsche" <foelsche_at_[hidden]> wrote in message
news:iv8fia$6gl$1_at_dough.gmane.org...
>
> "Peter Foelsche" <foelsche_at_[hidden]> wrote in message
> news:iv8fap$5ju$1_at_dough.gmane.org...
>
> something was missing:
>
>
>> std::list<object*> sort(std::list<object*> _sList)
>> { std::set<object*> sSet;
>> std::list<object*> sSorted;
>> while (_sList.size())
>> for (std::list<object*>::iterator p = _sList.begin(), pNext = p, pEnd
>> = _sList.end();
>> p != pEnd;
>> p = pNext)
>> { ++pNext;
>> bool bFound = false;
>> for (std::set<object*>::const_iterator p1 =
>> (*p)->m_sPredecessors.begin(), p1End = (*p)->m_sPredecessors.end();
>> p1 != p1End;
>> ++p1)
>> if (sSet.find(*p1) == sSet.end())
>> { bFound = true;
>> break;
>> }
>> if (!bFound)
>> { sSorted.push_back(*p);
> sSet.insert(*p);
>> _sList.erase(p);
>> }
>> }
>> return sSorted;
>> }
ok -- one could use
std::includes
http://www.cplusplus.com/reference/algorithm/includes/
to find out if all elements of the set attached to the object currently
considered
are contained in the local sSet
instead of iterating...
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net