[Range] Proposal to add a new range adaptor (first_nd), or modify sliced
Hi,
Problem:
Get the first N element of a SinglePassRange. It is not possible with
sliced, because it requires RandamAccessRange.
(Similar discussion was on the list about this in 2011 January:
http://lists.boost.org/boost-users/2011/01/65757.php)
Possible solutions:
A)
Modify sliced implementation to use std::advance instead of
boost::size. (Boost::size calls operator+ on the end iterator of the
adapted range, that is why it requires the random access.)
However using std::advance is not efficient in case of iterators which
are not random access ones. I think this efficiency problem is the
reason why the author(s) decided to not use std::advance, but rather
boost::size. So this is not a real solution.
B)
Introduce a new range adaptor, which has an underlying adapted
iterator with a "count" member:
template <class Iterator>
class first_n_iterator : public
boost::iterator_adaptor
Problem: Get the first N element of a SinglePassRange. It is not possible with sliced, because it requires RandamAccessRange.
Note that this is possible with the 'taken' range adaptor [1] in the Boost.Range Extensions library [2] proposed by Akira Takahashi, which is on the review schedule [3], atlhough with no review date set yet. The equivalent of sliced(n, m) for SinglePassRanges is also possible by combining the 'taken' and 'dropped' [4] adaptors from that library: range | taken(n) | dropped(m) // same elements as 'range | sliced(n, m)' Regards, Nate [1] http://dl.dropbox.com/u/1682460/git/OvenToBoost/libs/range/doc/html/range_ex... [2] http://dl.dropbox.com/u/1682460/git/OvenToBoost/libs/range/doc/html/index.ht... [3] http://www.boost.org/community/review_schedule.html [4] http://dl.dropbox.com/u/1682460/git/OvenToBoost/libs/range/doc/html/range_ex...
Dear all, On Monday, August 27, 2012, Nathan Ridge wrote:
Problem: Get the first N element of a SinglePassRange. It is not possible with sliced, because it requires RandamAccessRange.
Note that this is possible with the 'taken' range adaptor [1] in the Boost.Range Extensions library [2] proposed by Akira Takahashi, which is on the review schedule [3], atlhough with no review date set yet.
I wonder if this is the best plan. In my time following Boost we have already had two reviews for Boost.Range. These additions appear to be incremental and cohesive with the existing design idioms. Would it be more appropriate to have me spend some time bringing the functionality into the trunk of Boost.Range? I would imagine we could deliver the desired result more quickly for Boost.Range and reduced the queue size to the benefit of other components? I promise to be less rubbish than I have been the past few months looking after my Trac tickets!
The equivalent of sliced(n, m) for SinglePassRanges is also possible by combining the 'taken' and 'dropped' [4] adaptors from that library:
range | taken(n) | dropped(m) // same elements as 'range | sliced(n, m)'
Regards, Nate
I'd be interested in the communities preferences with regard to choosing another review, or expedited merge. Regards, Neil Groves
2012/8/31 Neil Groves
Dear all,
On Monday, August 27, 2012, Nathan Ridge wrote:
Problem: Get the first N element of a SinglePassRange. It is not possible with sliced, because it requires RandamAccessRange.
Note that this is possible with the 'taken' range adaptor [1] in the Boost.Range Extensions library [2] proposed by Akira Takahashi, which is on the review schedule [3], atlhough with no review date set yet.
I wonder if this is the best plan. In my time following Boost we have already had two reviews for Boost.Range. These additions appear to be incremental and cohesive with the existing design idioms.
Would it be more appropriate to have me spend some time bringing the functionality into the trunk of Boost.Range? I would imagine we could deliver the desired result more quickly for Boost.Range and reduced the queue size to the benefit of other components? I promise to be less rubbish than I have been the past few months looking after my Trac tickets!
The equivalent of sliced(n, m) for SinglePassRanges is also possible by combining the 'taken' and 'dropped' [4] adaptors from that library:
range | taken(n) | dropped(m) // same elements as 'range | sliced(n, m)'
Regards, Nate
I'd be interested in the communities preferences with regard to choosing another review, or expedited merge.
I agree with that. I prefer marging to trunk, rather than wating for a formal review. At any rate, I'll cooperate with AFAP. Regards, Akira
======================== Akira Takahashi site: https://sites.google.com/site/faithandbrave/about/en
2012/8/31 Akira Takahashi
2012/8/31 Neil Groves
: Dear all,
On Monday, August 27, 2012, Nathan Ridge wrote:
I'd be interested in the communities preferences with regard to choosing another review, or expedited merge.
I agree with that. I prefer marging to trunk, rather than wating for a formal review.
I think it should be a merge also. In fact all library extensions should be just a part of usual maintenance and under owner's (current maintainer's) eye only. Library itself is accepted, extensions obviously follow design decisions of original so it really only comes down to making sure that implementations is good enough. Scheduling full review makes no sense imho as library usability and the design is already agreed upon. Regards, Szymon Gatner
On 8/31/2012 2:56 AM, Szymon Gatner wrote:
2012/8/31 Akira Takahashi
: 2012/8/31 Neil Groves
: Dear all,
On Monday, August 27, 2012, Nathan Ridge wrote:
I'd be interested in the communities preferences with regard to choosing another review, or expedited merge.
I agree with that. I prefer marging to trunk, rather than wating for a formal review.
I think it should be a merge also. In fact all library extensions should be just a part of usual maintenance and under owner's (current maintainer's) eye only. Library itself is accepted, extensions obviously follow design decisions of original so it really only comes down to making sure that implementations is good enough. Scheduling full review makes no sense imho as library usability and the design is already agreed upon.
+1 Jeff
Neil Groves wrote:
Would it be more appropriate to have me spend some time bringing the functionality into the trunk of Boost.Range? I would imagine we could deliver the desired result more quickly for Boost.Range and reduced the queue size to the benefit of other components? I promise to be less rubbish than I have been the past few months looking after my Trac tickets!
FYI, Boost.Spirit has "Spirit Repository" : The Spirit repository is a community effort collecting different reusable components (primitives, directives, grammars, etc.) for Spirit.Qi parsers and Spirit.Karma generators. All components in the repository have been peer reviewed or discussed on the Spirit General List. For more information about the repository see here. ( http://boost-sandbox.sourceforge.net/libs/spirit/repository/doc/html/ ) Regards, Michel
participants (7)
-
Akira Takahashi
-
Gábor Márton
-
Jeff Flinn
-
Michel Morin
-
Nathan Ridge
-
Neil Groves
-
Szymon Gatner