Skip to content

Commit cc14205

Browse files
committed
Weighted range refactoring.
1 parent 6ab62aa commit cc14205

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

include/react/common/TopoQueue.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,20 @@ struct NodeWeightHelper<T*>
9696

9797
template
9898
<
99-
typename TValue,
99+
typename TIt,
100100
uint grain_size
101101
>
102102
class WeightedRange
103103
{
104104
public:
105-
using const_iterator = TValue;
105+
using const_iterator = TIt;
106+
using ValueT = typename TIt::value_type;
107+
using WeightFunctorT = NodeWeightHelper<ValueT>;
106108

107109
WeightedRange() = default;
108110
WeightedRange(const WeightedRange& other) = default;
109111

110-
WeightedRange(const TValue& a, const TValue& b, uint weight) :
112+
WeightedRange(const TIt& a, const TIt& b, uint weight) :
111113
begin_{ a },
112114
end_{ b },
113115
weight_{ weight }
@@ -117,10 +119,10 @@ class WeightedRange
117119
WeightedRange(WeightedRange& source, tbb::split)
118120
{
119121
uint sum = 0;
120-
TValue p = source.begin_;
122+
TIt p = source.begin_;
121123
while (p != source.end_)
122124
{
123-
sum += (*p)->Weight;
125+
sum += WeightFunctorT{}(*p);
124126
++p;
125127
if (sum >= grain_size)
126128
break;
@@ -148,8 +150,8 @@ class WeightedRange
148150
uint Weight() const { return weight_; }
149151

150152
private:
151-
TValue begin_;
152-
TValue end_;
153+
TIt begin_;
154+
TIt end_;
153155
uint weight_ = 0;
154156
};
155157

0 commit comments

Comments
 (0)