5 // Created by James McIlree on 4/14/13.
6 // Copyright (c) 2013 Apple. All rights reserved.
9 #ifndef __CPPUtil__UtilAbsInterval__
10 #define __CPPUtil__UtilAbsInterval__
12 typedef TRange<AbsTime> AbsInterval;
14 struct AbsIntervalLocationVsAbsTimeComparator {
15 bool operator()(const AbsInterval& activity, const AbsTime& time) const {
16 return activity.location() < time;
19 bool operator()(const AbsTime& time, const AbsInterval& activity) const {
20 return time < activity.location();
24 struct AbsIntervalMaxVsAbsTimeComparator {
25 bool operator()(const AbsInterval& activity, const AbsTime& time) const {
26 return activity.max() < time;
29 bool operator()(const AbsTime& time, const AbsInterval& activity) const {
30 return time < activity.max();
35 // Takes a vector of sorted non overlapping AbsInterval(s), and a timespan. Returns a pointer to the
36 // youngest AbsInterval that intersects the timespan. Returns NULL if no interval intersects.
38 // vec: XXXXXXX XXXXXXXX XXXXX XXXXXX
39 // ts: MMMMMMMMMMMMMMM
42 // ----------------------------------
44 // vec: XXXXXXXX XXXXX XXXXXX
45 // ts: MMMMMMMMMMMMMMM
48 // ----------------------------------
51 // ts: MMMMMMMMMMMMMMM
54 // ----------------------------------
57 // ts: MMMMMMMMMMMMMMM
61 const AbsInterval* interval_beginning_timespan(const std::vector<AbsInterval>& intervals, AbsInterval timespan);
64 // Takes a vector of sorted non overlapping AbsInterval(s), and a timespan. Returns a pointer to the
65 // oldest AbsInterval that intersects the timespan. Returns NULL if no interval intersects.
67 // vec: XXXXXXX XXXXXXXX XXXXX XXXXXX
68 // ts: MMMMMMMMMMMMMMM
71 // ----------------------------------
73 // vec: XXXXXXXX XXXXX XXXXXX
74 // ts: MMMMMMMMMMMMMMM
77 // ----------------------------------
80 // ts: MMMMMMMMMMMMMMM
83 // ----------------------------------
86 // ts: MMMMMMMMMMMMMMM
90 const AbsInterval* interval_ending_timespan(const std::vector<AbsInterval>& intervals, AbsInterval timespan);
92 #endif /* defined(__CPPUtil__UtilAbsInterval__) */