Changeset 371
Legend:
 Unmodified
 Added
 Removed

trunk/lib/Stats.cc
r361 r371 187 187 double yrange_max=1.03*total.back()+1; 188 188 gp>yrange(yrange_max); 189 size_t plotno=1; 189 190 191 typedef std::vector<std::pair<std::string, std::vector<u_int> > > vec_type; 192 vec_type author_cont; 193 author_cont.reserve(stat>size()); 194 for (MapConstIter_ i= stat>begin(); i != stat>end(); ++i) { 195 author_cont.push_back(std::make_pair(i>first, 196 accumulated(*stat,i>first))); 197 } 198 199 LessReversed<std::vector<u_int> > lr; 200 PairSecondCompare<std::string, std::vector<u_int>, 201 LessReversed<std::vector<u_int> > > compare(lr); 202 std::sort(author_cont.begin(), author_cont.end(), compare); 203 204 size_t plotno=author_cont.size(); 190 205 std::stringstream ss; 191 for (MapConstIter_ i= stat>begin(); i != stat>end(); ++i) { 206 vec_type::iterator end(author_cont.end()); 207 for (vec_type::iterator i(author_cont.begin()); i!=end; ++i) { 192 208 ss.str(""); 193 209 ss << "set key height " << 2*plotno; 194 210 gp>command(ss.str()); 195 std::vector<u_int> x=accumulated(*stat, i>first);196 211 ss.str(""); 197 ss << x.back() << " " << i>first;212 ss << i>second.back() << " " << i>first; 198 213 gp>yrange(yrange_max); 199 214 gp>linetitle(ss.str()); 200 215 ss.str(""); 201 ss << "steps " << ++plotno;216 ss << "steps " << plotno+2; 202 217 gp>linestyle(ss.str()); 203 gp>plot( x);218 gp>plot(i>second, ss.str()); 204 219 } 205 220 ss.str(""); 
trunk/lib/utility.h
r313 r371 144 144 145 145 146 template < classT>146 template <typename T> 147 147 std::string match(std::string::const_iterator& first, 148 148 const std::string::const_iterator& last, … … 184 184 }; 185 185 186 186 187 class not2Char 187 188 { … … 211 212 212 213 /// 214 /// Functor to be used on contaioners and works as standard less, 215 /// but on the reversed container. 216 /// 217 /// Requirements on T is that has rend and rbegin. T::value_type 218 /// must be comparable (i.e. have operator<) 219 /// 220 template <typename T> 221 struct LessReversed 222 { 223 /// 224 /// using std::lexicographical_compare on the reversed container 225 /// 226 inline bool operator()(const T& x, const T& y) const 227 { return std::lexicographical_compare(x.rbegin(),x.rend(), 228 y.rbegin(),y.rend()); } 229 }; 230 231 232 /// 213 233 /// @brief Functor comparing pairs using second. 214 234 /// … … 217 237 /// comparison object in generic functions such as the STL sort. 218 238 /// 219 template < class T1,classT2>239 template <typename T1, typename T2> 220 240 struct pair_value_compare 221 241 { … … 231 251 }; 232 252 233 template <class T1,class T2, class T3> 253 254 /// 255 /// Functor working on pair.second, using a user passed functor. 256 /// 257 template <typename T1, typename T2, typename T3> 234 258 struct PairSecondCompare 235 259 { … … 242 266 243 267 /// 244 /// @return true if x.second<y.second or (x.second==y.second and245 /// x.first<y.first)268 /// @return compare(x.second, y.second) where compare is a 269 /// internal comparison functor. 246 270 /// 247 271 inline bool operator()(const std::pair<T1,T2>& x, … … 253 277 254 278 }; 255 279 256 280 /// 257 281 /// Calculating sum of two vectors.
Note: See TracChangeset
for help on using the changeset viewer.