Ignore:
Timestamp:
Nov 9, 1999, 3:04:05 PM (26 years ago)
Author:
ansari
Message:

portage cxx en cours

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Poubelle/archTOI.old/toiproducer.cc

    r534 r555  
    5757  // should be nothing left
    5858  if (!extraopts.empty()) return false;
    59  
     59
    6060  return true;
    6161}
     
    129129
    130130class comp2nd { public:bool operator()(pair<long, double> const& a, long b) {return a.first<b;}};
    131 
    132 deque<pair<long, double> >::const_iterator TOIProducer::findHist(TOI const& toi,long sampleNum) {
     131class comp2ndI { public:bool operator()(long a, pair<long, double> const& b) {return a<b.first;}};
     132
     133deque<pair<long, double> >::const_iterator TOIProducer::findHistL(TOI const& toi,long sampleNum) {
    133134  CHKPROD
    134135  deque<pair<long, double> >& h = history[toi.ref];
     
    136137}
    137138
    138 deque<pair<long, double> >::const_iterator TOIProducer::findHist(deque<pair<long, double> >& h,long sampleNum) {
     139deque<pair<long, double> >::const_iterator TOIProducer::findHistL(deque<pair<long, double> >& h,long sampleNum) {
    139140  return lower_bound(h.begin(), h.end(), sampleNum, comp2nd());
    140141}
     142
     143deque<pair<long, double> >::const_iterator TOIProducer::findHistH(TOI const& toi,long sampleNum) {
     144  CHKPROD
     145  deque<pair<long, double> >& h = history[toi.ref];
     146  return upper_bound(h.begin(), h.end(), sampleNum, comp2ndI());
     147}
     148
     149deque<pair<long, double> >::const_iterator TOIProducer::findHistH(deque<pair<long, double> >& h,long sampleNum) {
     150  return upper_bound(h.begin(), h.end(), sampleNum, comp2ndI());
     151}
     152
    141153
    142154bool TOIProducer::canGetValue(long sampleNum, TOI const& toi) {
     
    145157  if (h.empty()) return false;
    146158  if (sampleNum < h.front().first || sampleNum > h.back().first) return false;
    147   deque<pair<long, double> >::const_iterator i = findHist(h, sampleNum);
     159  deque<pair<long, double> >::const_iterator i = findHistL(h, sampleNum);
    148160  if (i == h.end()) return false;
    149161  return ((*i).first == sampleNum);
     
    163175  deque<pair<long, double> >& h = history[toi.ref];
    164176  if (h.empty()) return false;
    165   return (sampleNum > h.back().first && sampleNum <= h.front().first);
     177  return (sampleNum > h.front().first && sampleNum <= h.back().first);
    166178   // Must be inside, otherwise we don't know if it is prev or simply past
    167179}
     
    171183  deque<pair<long, double> >& h = history[toi.ref];
    172184  if (h.empty()) return false;
    173   return (sampleNum >= h.back().first && sampleNum < h.front().first);
     185  return (sampleNum >= h.front().first && sampleNum < h.back().first);
    174186}
    175187
     
    179191//       << h.front().first
    180192//       << " " << h.back().first << endl;
    181   deque<pair<long, double> >::const_iterator i = findHist(h, sampleNum);
     193  deque<pair<long, double> >::const_iterator i = findHistL(h, sampleNum);
    182194  if (i == h.end()) return -999999;
    183195//  cout << "found " << (*i).first << endl;
     
    189201double TOIProducer::getPrevValue(long& sampleNum, TOI const& toi) {
    190202  deque<pair<long, double> >& h = history[toi.ref];
    191   deque<pair<long, double> >::const_iterator i = findHist(h, sampleNum);
     203  deque<pair<long, double> >::const_iterator i = findHistH(h, sampleNum);
    192204  if (i == h.end()) return -999999;
    193   if ((*i).first == sampleNum) {
     205  pair<long, double> tstpair = *i;
     206  while ((*i).first >= sampleNum) {
    194207    if (i == history[toi.ref].begin()) {sampleNum = -99999 ;return -9999;}
    195208    i--;
    196209  }
     210  tstpair = *i;
    197211  sampleNum = (*i).first;
    198212  return (*i).second;
     
    201215double TOIProducer::getNextValue(long& sampleNum, TOI const& toi) {
    202216  deque<pair<long, double> >& h = history[toi.ref];
    203   deque<pair<long, double> >::const_iterator i = findHist(h, sampleNum);
     217  deque<pair<long, double> >::const_iterator i = findHistL(h, sampleNum);
    204218  if (i == h.end()) return -999999;
    205   if ((*i).first == sampleNum) {
     219  pair<long, double> tstpair = *i;
     220  while ((*i).first <= sampleNum) {
    206221    if (i == history[toi.ref].end()) {sampleNum = -99999 ;return -9999;}
    207222    i++;
    208223  }
     224  tstpair=*i;
    209225  sampleNum = (*i).first;
    210226  return (*i).second;
     
    212228
    213229void TOIProducer::computedValue(TOI const& toi, long sampleNum, double value) {
    214   map<int, deque<pair<long, double> > >::iterator i = history.find(toi.ref);
    215   if (i == history.end()) throw ArchExc("computedValue : bad TOI " + toi.name);
    216   deque<pair<long, double> >& h = (*i).second;
     230  //map<int, deque<pair<long, double> > >::iterator i = history.find(toi.ref);
     231  //if (i == history.end()) throw ArchExc("computedValue : bad TOI " + toi.name);
     232  //deque<pair<long, double> >& h = (*i).second;
     233  deque<pair<long, double> >& h = history[toi.ref];
    217234  if (!h.empty() && sampleNum <= h.back().first)
    218235    throw ArchExc("computedValue : sampleNum not in sequence for " + toi.name);
    219236  h.push_back(pair<long,double>(sampleNum,value));
    220  
    221237  for (map<TOIAbsorber*, set<TOI> >::iterator j = clients.begin(); j != clients.end(); j++) {
    222238    set<TOI>& tois = (*j).second;
Note: See TracChangeset for help on using the changeset viewer.