6 Aralık 2017 Çarşamba

icl

interval_map Sınıfı
Örnek ver.

interval_set Sınıfı
Giriş
Şu satırı dahil ederiz.
#include <boost/icl/interval_set.hpp>
operator += metodu
Şöyle yaparız.
typedef icl::discrete_interval<unsigned int> Interval;
typedef icl::interval_set<unsigned int> IntervalSet;


// Vector of pairs <epoch, value>
std::vector<std::pair<unsigned int, double>> simulatedValues = {
  std::make_pair<unsigned int, double>(1000, 44.4),
  std::make_pair<unsigned int, double>(1060, 55.5),
  std::make_pair<unsigned int, double>(1120, 66.6),
  std::make_pair<unsigned int, double>(1180, 77.7),
  std::make_pair<unsigned int, double>(1240, 88.8),
  std::make_pair<unsigned int, double>(1300, 77.7),
  std::make_pair<unsigned int, double>(1360, 66.6),
  std::make_pair<unsigned int, double>(1420, 47.7),
  std::make_pair<unsigned int, double>(1480, 99.9),
  std::make_pair<unsigned int, double>(1540, 33.3)};
const double testThreshold = 50.0;
IntervalSet alerts;

// Create interval set from those epochs where the value is greater than the threshold
for(auto timeValPair : simulatedValues) {
  unsigned int time = timeValPair.first;
  double value = timeValPair.second;
  if(value > testThreshold) {
    alerts += Interval::closed(time, time);
  }
}

Hiç yorum yok:

Yorum Gönder