diff --git a/src/lib/iter-source.hpp b/src/lib/iter-source.hpp index f887b4c21..a18de84e0 100644 --- a/src/lib/iter-source.hpp +++ b/src/lib/iter-source.hpp @@ -51,6 +51,7 @@ #include "lib/iter-adapter.hpp" #include "lib/itertools.hpp" +#include #include #include @@ -259,8 +260,8 @@ namespace lib { { typedef typename MAP::key_type Key; typedef typename MAP::value_type::second_type Val; - typedef typename IterSource::iterator KeyIter; - typedef typename IterSource< Val>::iterator ValIter; + typedef typename IterSource::iterator KeyIter; + typedef typename IterSource::iterator ValIter; }; @@ -275,8 +276,12 @@ namespace lib { struct _PairIterT { typedef typename IT::value_type PairType; - typedef typename PairType::first_type KeyType; typedef typename PairType::second_type ValType; + typedef typename PairType::first_type ConstKeyType; + + // since we're returning the keys always by value, + // we can strip the const added by the STL map types + typedef typename boost::remove_const::type KeyType; typedef TransformIter KeyIter; typedef TransformIter ValIter; @@ -347,12 +352,17 @@ namespace lib { /** @return a Lumiera Forward Iterator to yield * all \em distinct keys of a Multimap + * @warning we do a full table scan to find + * the distinct keys */ template typename _MapT::KeyIter - eachDistinctKey (MAP&) // map) + eachDistinctKey (MAP& map) { - UNIMPLEMENTED ("standard iter wrapper yielding all distinct keys of a multimap"); + typedef RangeIter Range; + + Range contents (map.begin(), map.end()); + return wrapIter (filterRepetitions (takePairFirst(contents))); } diff --git a/src/proc/mobject/session/placement-index.cpp b/src/proc/mobject/session/placement-index.cpp index 395e5059e..fb8a12b06 100644 --- a/src/proc/mobject/session/placement-index.cpp +++ b/src/proc/mobject/session/placement-index.cpp @@ -305,7 +305,7 @@ namespace session { /* == access for self-test == */ - typedef lib::IterSource::iterator IDIter; + typedef lib::IterSource::iterator IDIter; PlacementMO* _root_4check () { return root_.get(); } PlacementMO* _element_4check (ID id){ return base_entry(id).element.get();} diff --git a/tests/40components.tests b/tests/40components.tests index cd8b9d9c6..847b9fa5c 100644 --- a/tests/40components.tests +++ b/tests/40components.tests @@ -363,6 +363,7 @@ out: (::X...........){13}$ out: (::00:0.:....00){13}$ out: (::X...........){13}$ out: (::00:0.:....00){13}$ +out: distinct_keys::0::1::2::3::4::5::6::7::8::9::10::11::12 END diff --git a/tests/lib/iter-source-test.cpp b/tests/lib/iter-source-test.cpp index 253b95d6f..3565f9c98 100644 --- a/tests/lib/iter-source-test.cpp +++ b/tests/lib/iter-source-test.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -50,8 +51,10 @@ namespace test{ using lib::test::randTime; using util::isnil; using util::cStr; + using std::make_pair; using std::string; using std::list; + using std::rand; using std::cout; using std::endl; @@ -149,12 +152,16 @@ namespace test{ typedef IterSource::iterator IntIter; typedef IterSource::iterator StrIter; - typedef IterSource::iterator StringIter; + typedef IterSource::iterator StringIter; typedef IterSource