Code:
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
class ShortPath
{
private:
struct List
{
List* node;
int f;
int h;
int g;
}*oRoot,*cRoot;
void listAdd(List* l);//operates list recursively
public:
ShortPath(vector<vector<char> >& m);//if mem just wants to just ge
ShortPath(vector<vector<char> >& m, vector<char>& data);//if mem wants to store path too.
~ShortPath();//don't forget to free up memory.
int getShortPathSteps(void);//returns number of steps from path
void findShortPath(vector<vector<char> >& m);//does not store path. Only FINDS
void getShortPath(vector<vector<char> >& m, vector<char>& d);//finds AND stores path
};
//constructor definition(1)[user doesn't want to store path]
ShortPath::ShortPath(vector<vector<char> >& maze)
{
oRoot = NULL;
cRoot = NULL;
findShortPath(maze);
}
//constructor definition(2)[user wants to retrieve path]:
ShortPath::ShortPath(vector<vector<char> >& maze, vector<char>& data)
{
oRoot = NULL;
cRoot = NULL;
getShortPath(maze,data);
}
void ShortPath::listAdd(List* node)
{
//add method for list recursively
}
//getShortPath definition(1)[finds path only]
void ShortPath::findShortPath(vector<vector<char> >& maze)
{
int x = 0;
int y = 0;
int c = 0;
//algorithm goes here
}
void ShortPath::getShortPath(vector<vector<char> >& maze, vector<char>& data)
{
int x = 0;
int y = 0;
int c = 0;
//algorithm goes here
}
int ShortPath::getShortPathSteps(void)
{
int count = 0;
//just recurse through cRoot and count how many nodes there are
return count;
}
ShortPath::~ShortPath(){}
Pretty sure that's what you meant right? Never got proper experience with vectors... I tried creating an instance of my class and passing a 2d vector in and it seemed to work. I put a cout statement in my constructor to print out the contents of the passed in 2d vector and it worked.
can someone tell me about std::map or w/e I heard about... it sounded like something that might be of interest to me.