[Range] sorted and randomized adaptors
Hello everybody, I know this might have been raised a few times before in this mailing list, but I'd like to know if it's possible(or otherwise what would prevent) to have sorted and randomized adaptors so that I may have a sorted and randomized view of a range respectively. Something like vector<int> x; // operations to fill x x | boost::adaptors::sorted; x | boost::adaptors::randomized;// That one might also take an optional random generator as a parameter. I understand that in this case the adaptor isn't entirely lazy as the adapted(x here) must be completely consumed before producing a single element in the resulting range. I want to know however if having such adaptors may contradict any basic principles of the existing adaptors. P.S. Two other threads I found that discussed the same idea(for sorted only): - http://lists.boost.org/Archives/boost/2009/03/149247.php - http://lists.boost.org/Archives/boost/2006/05/105122.php
On 01-11-2015 00:33, Mohammed El-Afifi wrote:
Hello everybody,
I know this might have been raised a few times before in this mailing list, but I'd like to know if it's possible(or otherwise what would prevent) to have sorted and randomized adaptors so that I may have a sorted and randomized view of a range respectively. Something like
vector<int> x; // operations to fill x x | boost::adaptors::sorted; x | boost::adaptors::randomized;// That one might also take an optional random generator as a parameter.
I understand that in this case the adaptor isn't entirely lazy as the adapted(x here) must be completely consumed before producing a single element in the resulting range.
Right.
I want to know however if having such adaptors may contradict any basic principles of the existing adaptors.
Well, you could say being lazy is the principle being violated. -Thorsten
On 10/31/15 7:33 PM, Mohammed El-Afifi wrote:
Hello everybody,
I know this might have been raised a few times before in this mailing list, but I'd like to know if it's possible(or otherwise what would prevent) to have sorted and randomized adaptors so that I may have a sorted and randomized view of a range respectively. Something like
vector<int> x; // operations to fill x x | boost::adaptors::sorted; x | boost::adaptors::randomized;// That one might also take an optional random generator as a parameter.
I understand that in this case the adaptor isn't entirely lazy as the adapted(x here) must be completely consumed before producing a single element in the resulting range. I want to know however if having such adaptors may contradict any basic principles of the existing adaptors.
P.S. Two other threads I found that discussed the same idea(for sorted only): - http://lists.boost.org/Archives/boost/2009/03/149247.php - http://lists.boost.org/Archives/boost/2006/05/105122.php
Check out http://ericniebler.com for related discussions and his range v3 library, which provide non lazy adaptors for the above. Jeff
participants (3)
-
Jeff Flinn
-
Mohammed El-Afifi
-
Thorsten Ottosen