Phase 1 for project 3:
Due Monday 1 May 2006 by 8:00am
Looking for Program 2 stuff? Phase4 p2
OOps!! I guess you guys had the wrong tests. Get the newer tests. Small changes.
I won't collect the turn directories until wednesday night. Rember this is worth 10%
Purpose of this assignment:
I updated the tests get the new ones.
- Familiarize yourself with the C++ STL Library's most useful collection the map
- Get used to the STL idioms: searching and iterating
- Learn about graph implementations and algorithms
For this phase you need to get just the 'V' and 'P' commands working.
For my script to score your work you must:
- put your files at the top level of your turn directory
- provide your own Makefile
- name your executable graph
There is a script just for the tests you need to pass for part1
It is called run_p3_phase1_tests.pl
Make sure you have read through the requirement document.
You will need to read a tutorial on using STL maps:
Things to know about maps:
- Lists always remain sorted by the key in ascending order
- Trying to retrieve the value of an key not stored in the map will create an entry for it, so use find() first
Make sure you know what you are doing with the map collection type and pairs.
Examples of declaring maps:
// must include the map header file
#include <map.h>
// map where the key is a string and the value is an int:
map<string, inti> id_map;
// add a username and a value
// key="admiral", value = 0
id_map["admiral"] = 0;
// print out the value associated with the key "admiral"
cout << id_map["admiral"] << endl;
// is the key "fvogt" in the map?
if (id_map.find("fvogt") != id_map.end())
cout << "fred is in the map" << endl;
// add some entries to the map
id_map["beavis"] = 1;
id_map["cleatus"] = 2;
id_map["stewy"] = 3;
id_map["brian"] = 4;
// iterate over the entire map
for (map::iterator map_itr = id_map.begin(); // make an iterator object, set it equal to the first pair
map_itr != id_map.end(); // stopping condition, has the iterator reached 1 past the last element?
map_itr++) // bump the iterator to the next key, value pair
{
cout << "username: " << map_itr->first << ", value: " << map_itr->second << endl;
}
Suggestions:
- Take a few days off but dive in and get this one over with
- Don't worry about making this program able to handle edges yet