Ive set to write an implementation for the Dijkstra pathfinding algorithm. Its a wip so please have patience with me. Im going to try not to use containers (Standard Template Library vector etc.). I will use the same array to store both visited and unvisited nodes. I know this will make the algorithm slow because I will have to traverse the entire array each time. Also Im not going to hold the nodes in structures. Im going to keep several arrays of the same dimension, one array for each structure member. I do all this because I find it easier going this route.
arbm and arim are arrays enveloped in a class. I did this wrapping to make the array safer to use.
arim::arim()
{
container = new int[800];
csize = 800;
};
arbm::arbm()
{
container = new bool[800];
csize = 800;
}
void arbm::Init(int contside)
{
side = contside;
}
void arim::Init(int contside)
{
side = contside;
}
bool arbm::G(int x, int z)
{
if(side > -1)
{
if((z * side + x < csize)&&(z * side + x > -1 ))
return container[z * side + x];
}
}
void arbm::S(int x, int z, bool value)
{
if(side > -1)
{
if((z * side + x < csize)&&(z * side + x > -1 ))
container[z * side + x] = value;
}
};
void arim::S(int x, int z, int value)
{
if(side > -1)
{
if((z * side + x < csize)&&(z * side + x > -1 ))
container[z * side + x] = value;
}
};
bool arbm::G(int index)
{
if(index < csize)
{
return container[index];
}
else
{
}
};
int arim::G(int index)
{
if(index < csize)
{
return container[index];
}
else
{
return -1;
}
};