+/**
+ * TODO: Think of a better than O(n^2) implementation.
+ * Possibly move to cache result
+ */
+std::vector<Interval> findIntervalsAtPoints(const vector<Interval>& intervals){
+ size_t max = intervals.size()+1;
+ vector<Interval> points(max,Interval(max,max));
+ size_t n = 0;
+ for (vector<Interval>::const_iterator i = intervals.begin(); i != intervals.end(); ++i, ++n){
+ if (points[i->first].first == max){
+ points[i->first].first = n;
+ }else
+ points[i->first].second = n;
+
+ if (points[i->second].first == max){
+ points[i->second].first = n;
+ }else
+ points[i->second].second = n;
+ }
+ return points;
+
+}