9 std::vector<std::pair<T0, uint>> mData;
11 void push(T0
const& item, uint weight) {
12 mData.emplace_back(item, weight);
13 mTotalWeight += weight;
15 void push(T0&& item, uint weight) {
16 mData.emplace_back(std::move(item), weight);
17 mTotalWeight += weight;
23 uint total()
const {
return mTotalWeight; }
25 size_t size()
const {
return mData.size(); }
27 bool empty()
const {
return mData.empty(); }
29 template <
typename Fn>
30 void erase_if(Fn&& fn) {
31 auto it = std::remove_if(mData.begin(), mData.end(), std::forward<Fn>(fn));
32 for (
auto i = it; i != mData.end(); ++i) {
33 mTotalWeight -= i->second;
35 mData.erase(it, mData.end());