#369 closed request (fixed)
create unweighted iterator from weighted iterator
Reported by: | Peter | Owned by: | Peter |
---|---|---|---|
Priority: | major | Milestone: | yat 0.5 |
Component: | utility | Version: | trunk |
Keywords: | Cc: |
Description (last modified by )
needed for ticket:366
related to ticket:368 and ticket:391
A weighted iterator points to a pair of data and weight. It would be useful to be able to create an unweighted iterator that points to either the data or weight. A possible interface could be to have a DataIterator
and WeightIterator
that are created from an iterator. Using the traits in iterator_traits would allow this to also work for an unweighted iterator (in case that is wanted).
Change History (9)
comment:1 follow-up: 7 Changed 15 years ago by
comment:3 Changed 15 years ago by
Owner: | changed from Jari Häkkinen to Peter |
---|---|
Status: | new → assigned |
comment:6 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:7 Changed 15 years ago by
Replying to peter:
It would be good if this adaptor could also be used to iterator over data in a map.
For example:
map<string, int> months; months["Jan"]=1; months["Feb"]=6; ... std::vector<int> vec(map.size()); copy(MyIter(months.begin()), MyIter(months.end()), vec.begin());
For this purpose one could use boost::transform_iterator with a unary function returning second()
, see http://www.boost.org/doc/libs/1_33_1/libs/iterator/doc/transform_iterator.html
In other words, no reason to add this functionality in yat.
comment:8 Changed 15 years ago by
(In [1399]) refs #369 added a function to create a boost::transform_iterator that was mentioned in ticket:369 - should probably add the corresponding for pair::second too.
It would be good if this adaptor could also be used to iterator over data in a map.
For example:
So we need a Adaptor that can be tailored to return different things for operator-> and *. The tailor suitable for doing the job, is likely a Policyclass. Then we can typedefs such as