24class Contour :
public std::vector< std::pair<double, T*> > {
33 for (
unsigned i=this->size()-1 ; i-- ; )
if ( this->at(i).second )
delete this->at(i).second;
36 void ranges(
const std::vector<double>& d, T* t ) {
37 if ( d.empty() )
return;
38 ranges( &d[0], d.size(), t );
41 void ranges(
const double* d,
unsigned N, T* t ) {
43 for (
unsigned i=1 ; i<N ; i++ ) {
44 this->push_back(
value_type( d[i-1],
new T(*t) ) );
51 if ( this->
empty() )
return 0;
52 for (
unsigned i=this->size()-1 ; i-- ; ) {
53 if ( d>=this->at(i).first && d<this->at(i+1).first )
return this->at(i).second;
60 void Write(
const std::string& s=
"") {
62 for (
unsigned i=this->size()-1 ; i-- ; ) {
63 if ( this->at(i).second ) {
65 if ( s==
"" ) std::sprintf( _name,
"%s_%d",
mname.c_str(), i-1 );
66 else std::sprintf( _name,
"%s_%d", s.c_str(), i-1 );
67 this->at(i).second->Bayes()->Write(_name);
85 s <<
"Contour : " << _c.
name() <<
"\n";
86 for (
unsigned i=0 ; i<_c.size() ; i++ ) s <<
"\t d " << _c[i].first <<
"\n";
std::ostream & operator<<(std::ostream &s, const Contour< T > &_c)
static const Attributes_t empty
std::pair< double, T * > value_type
Contour(const std::string &s)
void ranges(const double *d, unsigned N, T *t)
void ranges(const std::vector< double > &d, T *t)
void Write(const std::string &s="")