I/O function takes far too long //parses the text path vector into the engine
void Level::PopulatePathVectors(string pathTable)
{
    // Read the file line by line.
    ifstream myFile(pathTable);

        for (unsigned int i = 0; i &lt; nodes.size(); i++)
        {
            pathLookupVectors.push_back(vector&lt;vector&lt;int&gt;&gt;());

            for (unsigned int j = 0; j &lt; nodes.size(); j++)
            {
                string line;

                if (getline(myFile, line)) //enter if a line is read successfully
                {
                    stringstream ss(line);
                    istream_iterator&lt;int&gt; begin(ss), end;
                    pathLookupVectors[i].push_back(vector&lt;int&gt;(begin, end));
                }
            }
        }
    myFile.close();
}


This function is taking about 5 minutes to pass in a text file which is 744 * 744 lines long. Each line is a list of integers like this:

1 4 6 24 7 4 8 n


they can be of varying length. I have no idea why it's taking so long, but it needs to run in a matter of seconds, not minutes! The odd thing is that the same function in C# (in fact a very unoptimised version) does in fact only take seconds to run.

Could the problem be a setting?

This is a link to the path table it is parsing http://dl.dropbox.com/u/13519335/WepTestLevelPathTable.txt
I setup nodes.size() to return 744.
This then forces all 553536 to be read from the file.

When I run your code it completes in 3.8 seconds (with -O3 it takes 2.5 seconds).

If I update the code to reserve the appropriate amount of space in each vector we can reduce the time it takes to: 3.3 seconds (with -O3 2.2 seconds).

So for the 5 minute figure you are quoting there must be some other error in your code.

Comments on your code:

Pass no-mutable parameters by cost reference (to avoid the copy).

void Level::PopulatePathVectors(string pathTable)


Add lines to reserve the appropriate space in each vector. This will prevent multiple re-allocations of the vector while you read. This is important when you have a triply nested vector.

    pathLookupVectors.push_back(vector&lt;vector&lt;int&gt; &gt;());
    pathLookupVectors.reserve(nodes.size());                // Add this line

    for (unsigned int i = 0; i &lt; nodes.size(); i++)
    {
        pathLookupVectors.push_back(vector&lt;vector&lt;int&gt;&gt;());
        pathLookupVectors.back().reserve(nodes.size())      // Add this line


No Need to manually close the file.
see https://stackoverflow.com/q/748014/14065
Implementation using fstream failed evaluation

myFile.close();