// ==========================================================================
// $Id: vector_iter.cpp,v 1.3 2011/09/10 01:08:20 jlang Exp $
// CSI2372 example Code for lecture 10
// ==========================================================================
// (C)opyright:
//
//   Jochen Lang
//   SITE, University of Ottawa
//   800 King Edward Ave.
//   Ottawa, On., K1N 6N5
//   Canada. 
//   http://www.site.uottawa.ca
// 
// Creator: jlang (Jochen Lang)
// Email:   jlang@site.uottawa.ca
// ==========================================================================
// $Log: vector_iter.cpp,v $
// Revision 1.3  2011/09/10 01:08:20  jlang
// Updates F10
//
// Revision 1.2  2009/11/16 00:46:38  jlang
// Minor touch-up
//
// Revision 1.1  2006/11/05 18:17:03  jlang
// Initial check-in for lecture 10
//
//
// ==========================================================================
#include <iostream>
#include <vector>

using std::cout;
using std::endl;
using std::vector;


template <class T>
void printInOrder( T& container ) {
  // loop over the elements
  for ( typename T::iterator iter = container.begin();
	iter != container.end();
	++iter ) {
    // save to access *iter
    cout << *iter << ' ';
  }
  cout << endl;
  return;
}

template <class T>
void printInReverse( T& container ) {
  // loop over the elements backwards
  for ( typename T::reverse_iterator iter = container.rbegin();
	iter != container.rend();
	++iter ) {
    // save to access *iter
    cout << *iter << ' ';
  }
  cout << endl;
  return;
}


int main( int argc, char* argv[] ) {
  vector<int> iVec(25,0);
  int num = 0;
  // loop over the elements and set them to their rank
  for ( vector<int>::iterator iter = iVec.begin();
	iter != iVec.end();
	++iter ) {
    // save to access *iter
    *iter = num++;
  }
  cout << endl;

  cout << "Original Sequence: " << endl;
  printInOrder( iVec ); 
  cout << endl;
  cout << "Print in Reverse: " << endl;
  printInReverse( iVec );
  cout << endl;
}
