27 int main(
int argc,
const char * argv[]) {
30 using weight_type = int;
35 weight_type operator()(
const value_type& str)
const {
36 return (str.size() % 2 == 0) ? 1 : 0;
40 using my_cachedmeasure_type =
43 using my_weighted_deque_type =
46 my_weighted_deque_type d = {
"Let's",
"divide",
"this",
"sequence",
"of",
47 "strings",
"into",
"two",
"pieces" };
49 weight_type nb_even_length_strings = d.
get_cached();
50 std::cout <<
"nb even-length strings: " << nb_even_length_strings << std::endl;
52 my_weighted_deque_type f;
54 d.split([=] (weight_type v) {
return v >= nb_even_length_strings/2; }, f);
56 std::cout <<
"d = " << std::endl;
57 d.for_each([] (
value_type& s) { std::cout << s <<
" "; });
58 std::cout << std::endl;
59 std::cout << std::endl;
61 std::cout <<
"f = " << std::endl;
62 f.for_each([] (
value_type& s) { std::cout << s <<
" "; });
63 std::cout << std::endl;
measured_type get_cached() const
Returns cached measurement.
const int chunk_capacity
[weighted_split_example]
int main(int argc, const char *argv[])
Chunked-sequence functor.