SVN / public / code / vorlesung-09 / StlDemoMain.cpp

Revision 11340
Date
Committeral38
Download
// Copyright 2016, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Hannah Bast <bast@cs.uni-freiburg.de>.

#include <iostream>
#include <string>
#include "./StlDemo.h"

// Main function.
int main(int argc, char** argv) {
  // Parse command line arguments.
  if (argc != 2) {
    std::cout << "Usage: ./StlDemoMain <filename>" << std::endl;
    return 1;
  }
  std::string filename = argv[1];

  StlDemo sd;
  sd.readMovieInfo(filename);
  sd.sortByPopularity();

  // Output info about map.
  for (auto& pair : sd.moviesByYear) {
    std::cout << pair.first << "..." << std::endl;
    if (pair.first < 2000 || pair.first > 2014) continue;
    std::cout << pair.first << " : ";
    for (int i = 0; i < 3; i++) {
      std::cout << "\"" << pair.second[i].title << "\"";
      if (i < 2) std::cout << ", ";
    }
    std::cout << std::endl;
  }
}