5 //  Created by James McIlree on 11/7/12.
 
   6 //  Copyright (c) 2014 Apple. All rights reserved.
 
  10 // NOTE! activity match behavior explanation...
 
  12 // CPUActivity entries are contiguous, there are no holes in the timeline.
 
  14 // Note the operator< definitions above, std::lower_bounds is not using the
 
  15 // default AbsInterval <. The comparsions are against the interval(s) max() - 1.
 
  17 // std::lower_bound returns a match doing <=, std::upper_bound returns a match doing <
 
  21 // Okay, based on a better understanding of the behavior of xxx_bounds, this
 
  22 // should be switchable to std::upper_bounds using a comparator without the
 
  23 // subtraction, and so slightly more efficient.
 
  26 template <typename SIZE>
 
  27 const CPUActivity<SIZE>* MachineCPU<SIZE>::activity_for_timestamp(AbsTime timestamp) const {
 
  28         auto it = std::upper_bound(_timeline.begin(), _timeline.end(), timestamp, AbsIntervalMaxVsAbsTimeComparator());
 
  30         // The upper bound will report that 0 is lower than [ 10, 20 ), need to check contains!
 
  31         if (it != _timeline.end() && it->contains(timestamp)) {