> On Feb. 27, 2015, 1:18 p.m., Alexander Rojas wrote:
> > include/mesos/resources.hpp, line 302
> > <https://reviews.apache.org/r/31183/diff/4/?file=874692#file874692line302>
> >
> > Why not use `std::accumulate`?
Do you mean why we don't use `std::accumulate` instead of introducing this? or
do you mean why don't we use `std::accumulate` in the implementation?
For the former, it's because `std::accumulate` is harder to use, with having to
pass the iterators, etc. It's similar to `stout/set.hpp`'s `operator &` which
is a wrapper around `std::set_intersection`, or `contains` function which is a
wrapper around the `std::find(elems.begin(), elems.end(), elem) != elems.end()`
pattern.
For the latter, it would have to look something like:
```cpp
template <typename Iterable>
Resources sum(const Iterable& iterable) {
return std::accumulate(
std::begin(iterable),
std::end(iterable),
Resources(),
[](Resources& result, const Resources& resources) -> Resources & {
return result += resources;
});
}
```
Without lambdas however I think it's simpler to just write the for-loop.
- Michael
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/31183/#review74482
-----------------------------------------------------------
On Feb. 25, 2015, 1:16 a.m., Michael Park wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/31183/
> -----------------------------------------------------------
>
> (Updated Feb. 25, 2015, 1:16 a.m.)
>
>
> Review request for mesos, Alexander Rukletsov, Benjamin Hindman, Ben Mahler,
> and Jie Yu.
>
>
> Bugs: MESOS-2373
> https://issues.apache.org/jira/browse/MESOS-2373
>
>
> Repository: mesos
>
>
> Description
> -------
>
> See summary.
>
>
> Diffs
> -----
>
> include/mesos/resources.hpp da6d48871a0061d8bbf5e681dd6e7edac659d812
> src/common/resources.cpp 2c99b6884d7296099e19e2e3182cbe11b5e1e059
> src/master/allocator/allocator.hpp b67b8fddbd7a3fffc6fe24d5e77cd1db8cb6f69b
> src/master/allocator/mesos/allocator.hpp
> fb898f1175b61b442204e6e38c69ccc2838a646f
> src/master/allocator/mesos/hierarchical.hpp
> c0b1da75565d9dc7728c5566f01815234163fc47
> src/master/allocator/sorter/drf/sorter.hpp
> 4366710d6530b784aa5094813328d0e338239ba0
> src/master/allocator/sorter/drf/sorter.cpp
> 2f69f384b95ff20d3ee429a4570a8cffa74d8e8b
> src/master/allocator/sorter/sorter.hpp
> e2efb27b11dbea42dd73f81e5db0d6d2b0a6034b
> src/master/http.cpp 117c0ee720a60a1d8a25359028bad803f1fc2b07
> src/master/master.hpp d414061b1aa7b4cac6ab9a3cc14e8e028f9370d0
> src/master/master.cpp 76e217d16c03e587ea4c0afca94c58b2212f0f93
> src/tests/hierarchical_allocator_tests.cpp
> 93753d1c04159a04a733927a487eb69505438e32
> src/tests/mesos.hpp 6b9656b2b858df75e725aaa042c447b755899c87
> src/tests/sorter_tests.cpp 42442353afe7bd3d1a5b43992f8ae191ac19bdcd
>
> Diff: https://reviews.apache.org/r/31183/diff/
>
>
> Testing
> -------
>
> make check
>
>
> Thanks,
>
> Michael Park
>
>