aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-07-07 17:41:04 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-07-07 17:41:04 +0000
commitaf2eea64f30591c10e35f96be65ef859e9afda64 (patch)
treecc58c8d7b87739fd4d9f4b4149a4c47303c435d2
parentc56e814eeec40fa78402ccb15ea651d7af70f091 (diff)
downloadpaludis-af2eea64f30591c10e35f96be65ef859e9afda64.tar.gz
paludis-af2eea64f30591c10e35f96be65ef859e9afda64.tar.xz
Fix qo_group_by_slot.
-rw-r--r--paludis/package_database.cc16
-rw-r--r--paludis/package_database_TEST.cc10
2 files changed, 17 insertions, 9 deletions
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index a95c082..f79ba42 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -334,24 +334,22 @@ PackageDatabase::query(const Query & q, const QueryOrder query_order) const
{
/* if someone's bored, they can rewrite this to be a lot faster */
PackageIDComparator c(this);
- std::set<tr1::shared_ptr<const PackageID>, tr1::reference_wrapper<const PackageIDComparator> > s(
- result->begin(), result->end(), tr1::cref(c));
+ std::set<tr1::shared_ptr<const PackageID>, tr1::function<bool (tr1::shared_ptr<const PackageID>, tr1::shared_ptr<const PackageID>)> > s(
+ result->begin(), result->end(), tr1::bind(&PackageIDComparator::operator(), tr1::cref(c), _2, _1));
result.reset(new PackageIDSequence);
while (! s.empty())
{
- result->push_front(*previous(s.end()));
- s.erase(previous(s.end()));
+ result->push_front(*s.begin());
+ s.erase(s.begin());
- for (std::set<tr1::shared_ptr<const PackageID>, tr1::reference_wrapper<const PackageIDComparator> >::reverse_iterator
- i(s.rbegin()), new_i(i) ; i != s.rend() ; )
+ for (std::set<tr1::shared_ptr<const PackageID>, tr1::function<bool (tr1::shared_ptr<const PackageID>, tr1::shared_ptr<const PackageID>)> >::iterator
+ i(s.begin()) ; i != s.end() ; )
{
if ((*i)->name() == (*result->begin())->name() && (*i)->slot() == (*result->begin())->slot())
{
- new_i = next(i);
result->push_front(*i);
- s.erase(--(i.base()));
- i = new_i;
+ s.erase(i++);
}
else
++i;
diff --git a/paludis/package_database_TEST.cc b/paludis/package_database_TEST.cc
index 1fb6364..9c997e5 100644
--- a/paludis/package_database_TEST.cc
+++ b/paludis/package_database_TEST.cc
@@ -232,6 +232,16 @@ namespace test_cases
const tr1::shared_ptr<const PackageIDSequence> q8(p.query(query::Matches(c), qo_best_version_in_slot_only));
TEST_CHECK_EQUAL(join(indirect_iterator(q8->begin()), indirect_iterator(q8->end()), " "),
"cat/other-1:a::repo3 cat/pkg-3:b::repo2 cat/pkg-3:c::repo1 cat/pkg-4:a::repo1");
+
+ PackageDepSpec b("cat/pkg:a", pds_pm_permissive);
+ const tr1::shared_ptr<const PackageIDSequence> q9(p.query(query::Matches(b), qo_group_by_slot));
+ TEST_CHECK_EQUAL(join(indirect_iterator(q9->begin()), indirect_iterator(q9->end()), " "),
+ "cat/pkg-1:a::repo2 cat/pkg-1:a::repo1 cat/pkg-4:a::repo1");
+
+ PackageDepSpec a("cat/pkg[=1|=3]", pds_pm_permissive);
+ const tr1::shared_ptr<const PackageIDSequence> q10(p.query(query::Matches(a), qo_group_by_slot));
+ TEST_CHECK_EQUAL(join(indirect_iterator(q10->begin()), indirect_iterator(q10->end()), " "),
+ "cat/pkg-1:a::repo2 cat/pkg-1:a::repo1 cat/pkg-3:b::repo2 cat/pkg-3:c::repo1");
}
} package_database_query_order_test;