9 #ifndef ThePEG_Selector_H
10 #define ThePEG_Selector_H
13 #include "ThePEG/Config/ThePEG.h"
45 template <
typename T,
typename WeightType =
double>
51 typedef map<WeightType, T, less<WeightType> >
MapType;
84 WeightType
insert(WeightType d,
const T & t) {
85 typedef typename MapType::value_type value_type;
86 WeightType newSum =
theSum + d;
87 if ( newSum <=
theSum )
return d;
109 WeightType
erase(
const T &);
115 void replace(
const T & oldObject,
const T & newObject) {
117 if ( it->second == oldObject ) it->second = newObject;
131 T &
select(
double rnd,
double * remainder = 0) throw(range_error);
140 T & operator[](
double rnd) throw(range_error) {
return select(rnd); }
153 const T &
select(
double rnd,
double * remainder = 0)
const throw(range_error);
162 const T & operator[](
double rnd) const throw(range_error) {
return select(rnd); }
176 template <
typename RNDGEN>
177 T &
select(RNDGEN & rnd)
throw(range_error) {
179 T & t =
select(rnd(), &rem);
196 template <
typename RNDGEN>
197 const T &
select(RNDGEN & rnd)
const throw(range_error) {
199 const T & t =
select(rnd(), &rem);
244 template <
typename OStream>
245 void output(OStream &)
const;
250 template <
typename IStream>
251 void input(IStream &);
270 template <
typename OStream,
typename T,
typename WeightType>
271 OStream & operator<<(OStream & os, const Selector<T,WeightType> & s)
280 template <
typename IStream,
typename T,
typename WeightType>
290 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
291 #include "Selector.tcc"