#include <iostream>
#include <vector>
#include <algorithm>

#include "Tracer.h"

using namespace std;

// Template version of Iterator Question from Lecture 14
// The "typename" in the parameter list is needed so that
// the compiler knows that vector<T>::iterator is a type
// and not a field, since it doesn't know yet what T is.
template <typename T>
void OrderPair(typename vector<T>::iterator it1) {
  auto it2 = it1 + 1;
  if (*it2 < *it1) {
    auto tmp = *it2;
    *it2 = *it1;
    *it1 = tmp;
  }
}

void PrintOut(const Tracer &p) {
  cout << "  printout: " << p << endl;
}

int main(int argc, char **argv) {
  Tracer a, b, c;
  vector<Tracer> vec;

  vec.push_back(c);
  vec.push_back(a);
  vec.push_back(b);

  cout << "order first 2 elements:" << endl;
  OrderPair<Tracer>(vec.begin());
  cout << "done ordering!" << endl;
  for_each(vec.begin(), vec.end(), &PrintOut);

  return 0;
}