CMSC 162 -- Iterators:

Iterators

The iter.cpp file.
	
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

void print(const vector<int>& vec){
	cout << "[ ";
//	for(int a: vec){
//		cout << a << " ";
//	}
	for(auto  it = vec.begin(); it != vec.end(); ++it){
		cout << *it << " ";
	}

	cout << "]\n";
}

int main(){
	vector<int> stuff = {12, 6, 3, 13, -7, 7};
	print(stuff);
	stuff.push_back(42);
	print(stuff);
	
	sort(stuff.begin(),stuff.end());
	print(stuff);

	stuff.insert(stuff.begin()+3,-21);
	print(stuff);

	map<string,int> dict;
	dict["apple"] = 52;
	dict["peach"] = 3;
	dict["orange"] = 19;

	for(auto p :dict){
		cout << p.first << " " << p.second << endl;
	}


	return 0;

}