File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,18 +96,20 @@ struct NodeWeightHelper<T*>
9696
9797template
9898<
99- typename TValue ,
99+ typename TIt ,
100100 uint grain_size
101101>
102102class WeightedRange
103103{
104104public:
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
150152private:
151- TValue begin_;
152- TValue end_;
153+ TIt begin_;
154+ TIt end_;
153155 uint weight_ = 0 ;
154156};
155157
You can’t perform that action at this time.
0 commit comments