Bez tytułu

z Bulky Macaque, 3 dni temu, napisane w C++, wyświetlone 9 razy. [paste_expire] 10 miesiące.
URL https://pastebin.k4be.pl/view/2059934a Udostępnij
Pobierz wklejkę lub Pokaż surowy tekst
  1. // Find the iterators representing the lower bound of startRT and the upper bound of endRT,
  2. // i.e. the first point in rt vector >= startRT and first point > endRT.
  3. // If interpolate is true: extend the range before the startRT to previous data point
  4. // unless it's an exact match.
  5. // No interpolation is happening here (with rt vector), but the same interface is used to obtain
  6. // signal and baseline vectors where the interpolation at those additional points will happen.
  7. // Returns true if the extension of start_lb took place, and false otherwise.
  8. // The corresponding iterator positions are returned through start_lb and end_ub references.
  9. // The *end_ub will always have higher value than endRT, unless it's file->rt.cend().
  10. // Therefore, if interpolation is used, this data point can be substituted by endRT.
  11. // This function assumes that this.file is present. It will not crash, but wouldn't work either;
  12. // the iterators will be left unchanged.
  13. bool ChromTreeItem::getRTRangeIterators(double startRT, double endRT, bool interpolate,
  14.     QList<double>::const_iterator &start_lb, QList<double>::const_iterator &end_ub) {
  15.     bool set_before = false; // add point before lower_bound
  16.     if(!file) return false;
  17.     // Find the point at or larger than startRT
  18.     start_lb = std::lower_bound(file->rt.cbegin(), file->rt.cend(), startRT);
  19.     // Find first point larger than endRT
  20.     end_ub = std::upper_bound(file->rt.cbegin(), file->rt.cend(), endRT);
  21.     if(start_lb == end_ub) {
  22.         // Iterators are the same - requested range doesn't intersect the rt vector
  23.         // This should construct an empty QVector
  24.     } else {
  25.         if(end_ub != file->rt.cend()) {
  26.             // The QVector constructor doesn't include the final position.
  27.             // We want it to be included.
  28.             ++end_ub;
  29.         }
  30.         // If interpolation is active and the value at start_lb is > startRT, then, if possible, extend the range
  31.         // by one element before start_lb (will not extend if start_lb == startRT).
  32.         if(interpolate && start_lb != file->rt.cbegin() && *start_lb > startRT) {
  33.             --start_lb;
  34.             set_before = true;
  35.         }
  36.     }
  37.     return set_before;
  38. }

odpowiedź "Bez tytułu"

Tutaj możesz odpowiedzieć na wklejkę z góry

captcha