Debugging vector retrieval? - c++

This is pretty much a followup from debugging a map insertion, I applied the suggestion pointed there, but now that even more pointers were needed I'm getting really puzzled by this:
#include <stdio.h>
#include <vector>
#include <stack>
#include <map>
using namespace std;
class Nodo
{
public:
vector<Nodo*> Relaciones;
int Valor;
bool Visitado;
Nodo(int V)
{
Valor = V;
Visitado = false;
}
Nodo()
{
Visitado = false;
}
};
class Grafo
{
public:
Nodo *Raiz;
map<int, Nodo*> Nodos;
Grafo(int V)
{
Raiz = new Nodo(V);
Nodos.insert(pair<int, Nodo*>(V, Raiz));
}
void Insertar(int _1, int _2)
{
Nodo *Fuente = Nodos[_1];
Nodo *Destino = new Nodo(_2);
Nodos.insert(pair<int, Nodo>(_2, Destino));
Fuente->Relaciones.push_back(Destino);
Destino->Relaciones.push_back(Fuente);
}
pair<int, Nodo> Resultado;
void DFS(Nodo Fuente)
{
stack<pair<int, Nodo>> St;
St.push(pair<int, Nodo>(0, Fuente));
Fuente.Visitado = true;
while(!St.empty())
{
pair<int, Nodo> P = St.top();
int Dist = P.first;
Nodo N = P.second;
St.pop();
if(Dist < Resultado.first)
{
Resultado.first = Dist;
Resultado.second = N;
}
for(int i = 0; i < N.Relaciones.size(); i++)
{
//Getting error C2664: 'Nodo::Nodo(int)' : cannot convert parameter 1 from 'Nodo *' to 'int' here
Nodo *I = N.Relaciones[i];
if(!I->Visitado)
{
I->Visitado = true;
St.push(pair<int, Nodo>(Dist + 1, I));
}
}
}
}
int Procesar()
{
DFS(*Raiz);
Resultado.first = 0;
DFS(Resultado.second);
return Resultado.first;
}
};
int main()
{
Grafo* G;
int Nodos = 0;
scanf("%d", &Nodos);
int _1, _2 = 0;
scanf("%d", &_1);
scanf("%d", &_2);
G = new Grafo(_1);
G->Insertar(_1, _2);
Nodos--;
while(Nodos - 1 > 0)
{
scanf("%d", &_1);
scanf("%d", &_2);
G->Insertar(_1, _2);
Nodos--;
}
printf("%d" + G->Procesar());
system("PAUSE");
}
Shouldn't it work as it is? I declare I as a pointer to Nodo, and the [] operator is meant to give me just that, a Nodo pointer.
If it is of importance, I'm using Visual Studio 2011 configured for no charset.

Since the map uses pointer, you need to insert a pair with pointer, change all
pair<int, Nodo>
to
pair<int, Nodo*>

I see a few problems with Insertar...
void Insertar(int _1, int _2)
{
Nodo *Fuente = Nodos[_1];
Nodo *Destino = new Nodo(_2);
Nodos.insert(pair<int, Nodo>(_2, Destino));
Fuente->Relaciones.push_back(Destino);
Destino->Relaciones.push_back(Fuente);
}
1) Nodos[_1] is not the way to find the entry associated with key _1 because it will create an entry in your map if one does not already exist. Please use map::find().
2) The insert of pair is being passed a Nodo*. That is incorrect.
I only looked at this function. I'm sure there are other issues.

Related

How to return structure array in C++

So I've been trying to implement Kruskal's algorithm, first I want to make clear the question is not related to the implementation of the algorithm. I've created one graph.hpp file, one kruskalsAlgo.hpp and main.cpp as follows respectively:
#pragma once
struct Edge
{
int source;
int destination;
int weight;
};
struct Graph
{
int V;
int E;
Edge* edge;
};
Graph* create_graph(int V, int E)
{
Graph* graph = new Graph;
graph -> V = V;
graph -> E = E;
graph -> edge = new Edge[E];
return graph;
}
#include <stdlib.h>
#include <tuple>
#include "../Graph/Graph.hpp"
class Kruskals_Algo
{
private:
struct subset
{
int parent;
int rank;
};
void make_set(subset*, int);
int find_set(subset*, int);
void _union(subset*, int, int);
public:
Edge* kruskal(Graph*);
void print_kruskals_MST(Edge*, int);
};
void Kruskals_Algo::make_set(subset* subsets, int V)
{
subsets[V].parent = V;
subsets[V].rank = 0;
}
int Kruskals_Algo::find_set(subset* subsets, int V)
{
if(subsets[V].parent != V)
subsets[V].parent = find_set(subsets, subsets[V].parent);
return subsets[V].parent;
}
void Kruskals_Algo::_union(subset* subsets, int x, int y)
{
int xroot = find_set(subsets, x);
int yroot = find_set(subsets, y);
if(subsets[xroot].rank < subsets[yroot].rank)
subsets[xroot].parent = yroot;
else if(subsets[xroot].rank > subsets[yroot].rank)
subsets[yroot].parent = xroot;
else
{
subsets[yroot].parent = xroot;
subsets[xroot].rank++;
}
}
inline int myComp(const void* a, const void* b)
{
Edge* a1 = (Edge*)a;
Edge* b1 = (Edge*)b;
return a1 -> weight > b1 -> weight;
}
Edge* Kruskals_Algo::kruskal(Graph* graph)
{
int V = graph -> V;
Edge result[V];
Edge* result_ptr = result;
int e = 0;
int i = 0;
qsort(graph -> edge, graph -> E, sizeof(graph -> edge[0]), myComp);
subset* subsets = new subset[(V * sizeof(subset))];
for (int v = 0; v < V; ++v)
make_set(subsets, v);
while(e < V - 1 && i < graph -> E)
{
Edge next_edge = graph -> edge[i++];
int x = find_set(subsets, next_edge.source);
int y = find_set(subsets, next_edge.destination);
if (x != y)
{
result[e++] = next_edge;
_union(subsets, x, y);
}
}
//return std::make_tuple(res, e);
return result_ptr;
}
void Kruskals_Algo::print_kruskals_MST(Edge* r, int e)
{
int minimumCost = 0;
for(int i=0; i<e; ++i)
{
std::cout << r[i].source << " -- "
<< r[i].destination << " == "
<< r[i].weight << std::endl;
minimumCost = minimumCost + r[i].weight;
}
std::cout << "Minimum Cost Spanning Tree: " << minimumCost << std::endl;
}
#include <iostream>
#include "Graph/Graph.hpp"
#include "Kruskals_Algo/kruskalsAlgo.hpp"
//#include "Prims_Algo/primsAlgo.hpp"
using namespace std;
class GreedyAlgos
{
public:
void kruskals_mst();
//void prims_mst();
};
void GreedyAlgos::kruskals_mst()
{
Kruskals_Algo kr;
int V;
int E;
int source, destination, weight;
cout << "\nEnter the number of vertices: ";
cin >> V;
cout << "\nEnter the number of edges: ";
cin >> E;
Edge* res;
Graph* graph = create_graph(V, E);
for(int i=0; i<E; i++)
{
cout << "\nEnter source, destinstion and weight: ";
cin >> source >> destination >> weight;
graph -> edge[i].source = source;
graph -> edge[i].destination = destination;
graph -> edge[i].weight = weight;
}
//std::tie(result, E) = kr.kruskal(graph);
res = kr.kruskal(graph);
kr.print_kruskals_MST(res, E);
}
int main()
{
int choice;
GreedyAlgos greedy;
greedy.kruskals_mst();
return 0;
}
So my question here is when I debug the program the values in Edge result[V], which is a structure array, are calculated correctly, at position [0] [1] [2] as in the following picture:
but when the function print_kruskals_MST(res, E) is called from the main the values printed are different:
Is there any pointer thing that I'm doing wrong?
Thanks in advance!
P.S. Ignore the comments!
This answer might not answer your question directly but it should shed some light on the problem.
First of all, yes you have a lot of pointer problems...
Secondly, pair ANY use of the new operator with the delete operator. As it stands, you have a bunch of memory leaks.
Also, why create_graph? Create a constructor for Graph instead (and a destructor since the class has an Edge* edge it needs to take care of).
struct Graph
{
int V;
int E;
Edge* edge;
// constructor
Graph(int V, int E)
{
this->V = V;
this->E = E;
this->edge = new Edge[E];
}
// destructor
~Graph()
{
// nullify the member variable before deleting its memory is just a safety measure pertaining to multithreading.
Edge* _edge = this->edge;
this->edge = nullptr;
delete _edge;
}
};
Then change Graph* graph = create_graph(V, E); into Graph* graph = new Graph(V, E); and do delete graph when you're done using it.
Make sure you remove all memory leaks and we can go on to discussing referencing the correct data (f.ex. by me changing my answer).

Issue Implementing A* in C++ with Priority Queues

I'm currently working on a homework assignment to implement A* for the sliding brick puzzle. I have previously implemented BFS and DFS for this puzzle, but an now having problems. I attempted to write my A* code by adapting the BFS code I already had working using a priority queue and Manhattan distance as the heuristic. In order to have the program open the node with the lowest f value (g+h), I had to override the operator for the priority queue, as it contains a defined structure. When I compile the code, no errors arise, but when I run it the program just crashed. My guess is that it is getting stuck in a loop somewhere. Maybe I implemented the operator override incorrectly. Can anyone help me figure out what is going wrong? I have pasted my code below.
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <time.h>
using namespace std;
struct move //creates structure for a move containing a pice number and direction to move
{
int piece;
char direction;
};
struct parentmove
{
vector< vector<int> > par;
move mo;
};
struct position
{
int row;
int column;
};
struct node
{
vector< vector<int> > par;
vector< vector<int> > state;
position pos;
int g;
int h;
int f;
};
bool operator<(const node& a, const node& b)
{
return a.f > b.f;
}
void SBP::Astar(vector <vector<int> > st)
{
position goalpos = getposition(st, -1);
node stnode;
stnode.state = st;
stnode.g = 0;
position stpos = getposition(st, 2);
stnode.h = abs(goalpos.row - stpos.row) + abs(goalpos.column - stpos.column);
stnode.f = stnode.g + stnode.h;
stnode.pos = stpos;
list<move> allm;
priority_queue< node > unexplored, explored;
set< vector <vector<int> > > closedset; //contains explored states in a set,
map < vector <vector<int> >, parentmove > pathdict;
allm = (*this).allmoves(st);
list<move>::iterator it = allm.begin();
for (int i = 0; i < allm.size(); i++)
{
move m;
m.piece = (*it).piece;
m.direction = (*it).direction;
vector< vector<int> > newst = (*this).applyMove(st, m);
newst = (*this).normalization(newst);
node newnode;
newnode.par = st;
newnode.state = newst;
newnode.g = 1;
position newpos = getposition(newst, 2);
newnode.h = abs(goalpos.row - newpos.row) + abs(goalpos.column - newpos.column);
newnode.f = newnode.h + newnode.g;
newnode.pos = newpos;
unexplored.push(newnode);
parentmove pm = { st,m };
pathdict[newst] = pm;
++it;
}
explored.push(stnode);
closedset.insert(st);
while (!unexplored.empty())
{
node currentnode = unexplored.top();
vector< vector<int> > currentst = currentnode.state;
unexplored.pop();
bool iscomplete = (*this).complete(currentst);
if (iscomplete)
{
explored.push(currentnode);
closedset.insert(currentst);
list<move> path = (*this).constructpath(currentst, pathdict, st);
(*this).display(currentst);
printf("A* explored %i nodes\n", explored.size());
printf("The length of the path solution is %i moves\n", path.size());
return;
}
else
{
set< vector< vector<int> > >::iterator ite = closedset.find(currentst);
if (ite == closedset.end()) //does not already exist in queue
{
list<move> possm;
possm = (*this).allmoves(currentst);
list<move>::iterator iter = possm.begin();
for (int j = 0; j < possm.size(); j++)
{
move m;
m.piece = (*iter).piece;
m.direction = (*iter).direction;
vector< vector<int> > newst = (*this).applyMove(currentst, m);
vector< vector<int> > normst = (*this).normalization(newst);;
node normnode;
normnode.state = normst;
normnode.par = currentst;
normnode.g = currentnode.g + 1;
position p = getposition(normst, 2);
normnode.h = abs(goalpos.row - p.row) + abs(goalpos.column - p.column);
normnode.f = normnode.g + normnode.h;
normnode.pos = p;
unexplored.push(normnode);
if (pathdict.find(normst) == pathdict.end())
{
parentmove pm = { currentst,m };
pathdict[normst] = pm;
}
++iter;
}
explored.push(currentnode);
closedset.insert(currentst);
}
}
}
return;
}

Vector::push_back not storing values in vector

Recently I've been trying to write a neural network program. I have all a neurons connections stored in a vector in the neuron. However whenever I push back a connection into the vector it doesn't seem to store (I can tell via debug mode), and when I try to add up the activation values of the vectors in a for loop, I get an out_of_range error. Here's my code.
Main.cpp
#include <iostream>
#include "neuron.h"
void displayboard(bool board [8][8]);
using namespace std;
int main()
{
int id = 2;
int inputids [] = {3};
int outputids [] = {4};
int inputweights [] = {5};
bool new_neuron = true;
neuron test (inputids, outputids, inputweights, new_neuron, id);
test.connections.at(0).value = 6;
// here is where the error is returned
test.activation();
cout << test.activationnumber;
return 0;
}
And here's Neuron.cpp:
#include "neuron.h"
#include <vector>
#include <random>
#include <ctime>
using namespace std;
neuron::neuron(int inputids [], int outputids [], int inputweights [],
bool new_neuron, int id)
{
this->id = id;
if (new_neuron==true) {
srand (time(0));
connection tempconnection;
for (int i = 0; i <=(sizeof (inputids)/sizeof (inputids [0])); i++)
{
tempconnection.type=false;
tempconnection.tofrom = inputids [i];
tempconnection.weight = rand ();
this->connections.push_back (tempconnection);
}
// this continues on for other options
}
void neuron::activation (){
for (int i=0; i<=this->connections.size (); i++) {
this->activationnumber += ((this->connections.at(i).value)
*(this->connections.at (i).weight));
}
}
UPDATE: Reading this will help you understand why your "sizeof/sizeof" approach is not good in C++.
Original answer
The behavior of sizeof(array)/sizeof(array[0]) might not be what you expected. The following code outputs 2 but you seem to expect 4. Use array for objects in the stack or vector for objects in the heap.
#include <iostream>
using namespace std;
void foo( int array[] )
{
wcout << sizeof( array ) / sizeof( array[ 0 ] );
}
int main()
{
int test[ 4 ];
foo( test );
return 0;
}
Change
int inputids [] = {3};
int outputids [] = {4};
to
vector< int > {3};
vector< int > {4};
Also change
neuron(int inputids [],int outputids [] …
{
…
for (int i = 0; i <= …; i++)
…
tempconnection.tofrom = inputids [i];
to
neuron( vector< int > & inputids, vector< int > & outputids …
{
…
for( auto id : inputids )
…
tempconnection.tofrom = id;

Vector subscript out of range when incrementing an int?

So strange situation, I am creating a list of structs, and then I am trying to update one of the list members with new values, and then move it back into the list.
I seem to be able to copy the values of the struct at iterator just fine, but when I attempt to update the value of the struct's member (using int++;) it throws an exception in the vector class of all things.
Any kind of explanation as to what might be happening here would be helpful.
struct Blob
{
int x;
int y;
};
list<Blob> blob;
// Add a Blob to blob using .push_back(); here
for(list<Blob>::iterator iterator=blob.begin(); iterator!=blob.end(); ++iterator)
{
Blob temp;
temp.x = ((Blob)*iterator).x;
temp.y = ((Blob)*iterator).y;
if (temp.x < 10 - 1)
temp.x++; /* Exception: vector: line 932 - "Vector subscript out of range" */
((Rain)*iterator) = temp;
}
When you want to update the existing value of object then take a reference of it. I have written a sample code to explain the same
#include<list>
#include<iostream>
using namespace std;
struct Test
{
int x;
int y;
};
int main()
{
list<Test> lTest;
int i = 0;
for(i=0;i<5;i++)
{
Test t1;
t1.x = i;
t1.y = i*i;
lTest.push_back(t1);
}
list<Test>::iterator lIter = lTest.begin();
for(;lIter != lTest.end();++lIter)
{
Test &t1 = *lIter;
cout<<"1 Val is:"<<t1.x<<"|"<<t1.y<<endl;
t1.x += 2;
t1.y += 2;
cout<<"2 Val is:"<<t1.x<<"|"<<t1.y<<endl;
}
lIter = lTest.begin();
for(;lIter != lTest.end();++lIter)
{
Test t1 = *lIter;
cout<<"3 Val is:"<<t1.x<<"|"<<t1.y<<endl;
}
return 0;
}
If you're writing a loop it's likely there's another way to do it. You can use std::for_each:
#include <list>
#include <algorithm>
struct Blob
{
int x;
int y;
};
void incrementXIfLessThanNine(Blob& blob)
{
if(blob.x < 9)
{
blob.x++;
}
}
int main()
{
std::list<Blob> blobs;
std::for_each(blob.begin(), blob.end(), incrementXIfLessThanNine);
return 0;
}
If you're using C++11:
#include <list>
struct Blob
{
int x;
int y;
};
int main()
{
std::list<Blob> blobs;
for(Blob& blob: blobs)
{
if(blob.x < 9)
{
blob.x++;
}
}
return 0;
}

Getting the coordinates of points from a Boost Geometry polygon

I have a simple DLL doing some calculations with Boost Geometry polygons. (Mostly intersections and differences.) Since the DLL will be most likely called from C# code, and from Delphi and who knows from where else, I should convert the result into arrays that everything can handle.
UPDATE:
I had simplified and somewhat corrected my code. The new code looks completely different, uses a completely different approach (for_each_point), and somehow still doesn't compile.
My new code:
#include <vector>
#include <boost/range.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/polygon.hpp>
using namespace boost::geometry;
typedef boost::geometry::model::point
<
double, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree>
> spherical_point;
class PointAggregator {
private :
double *x, *y;
int count;
public :
PointAggregator(int size) {
x = (double*) malloc(sizeof(double) * size);
y = (double*) malloc(sizeof(double) * size);
count = 0;
}
~PointAggregator() {
free(x);
free(y);
}
inline void operator()(spherical_point& p) {
x[count] = get<0>(p);
y[count] = get<1>(p);
count++;
}
void GetResult(double *resultX, double *resultY) {
resultX = x;
resultY = y;
}
};
void VectorToArray(std::vector<model::polygon<spherical_point>> resultVector, double x[], double y[], int *count) {
int i = 0;
for (std::vector<model::polygon<spherical_point>>::iterator it = resultVector.begin(); it != resultVector.end(); ++it) {
if (boost::size(*it) >= 2) {
*count = boost::size(*it);
PointAggregator* pa = new PointAggregator(*count);
boost::geometry::for_each_point(*it, *pa);
pa->GetResult(x, y);
delete(pa);
break;
}
}
}
The current compilation errors are:
error C2039: 'type' : is not a member of 'boost::mpl::eval_if_c' iterator.hpp 63
error C3203: 'type' : unspecialized class template can't be used as a template argument for template parameter 'Iterator', expected a real type difference_type.hpp 25
error C2955: 'boost::type' : use of class template requires template argument list difference_type.hpp 25
error C2955: 'boost::iterator_difference' : use of class template requires template argument list difference_type.hpp 26
Which ones don't look like they have anything to do with this part of code (my filename is geometry.cpp), but everything else that uses Boost Geometry is commented out and I still get these errors, so...
Here is my bad code that I had previously (edited by sehe)
(I'm new to C++ and Boost so I might have missed some basic concept while putting code from the internet together.)
I assume that I can just not iterate through a polygon that easily and I missed the non-trivial part, or that a polygon can not be used as a ring, or iterations are just not the way I thought they are, or I have no idea what else can be wrong. What did I do wrong?
Ok, I think I've got what you're looking for here.
I still don't quite understand why you're looking for this range of what I assume to be points greater than or equal to 2, but I figured out how to get it to compile when using boost::size() at least.
First off, realize that the first parameter of the function
void VectorToArray(std::vector<model::polygon<spherical_point> > resultVector, double x[], double y[], int *count)
{
...
}
is a std::vector containing instances of type model::polygon.
This means that when you dereference your iterator ...defined as
std::vector<model::polygon<spherical_point> >::iterator it
the rvalue is a model::polygon.
boost::model::polygon is NOT in and of itself Boost.Range compatible.
boost::model::polygon is a type containing 5 member functions ....
inline ring_type const& outer() const { return m_outer; }
inline inner_container_type const& inners() const { return m_inners; }
inline ring_type& outer() { return m_outer; }
inline inner_container_type & inners() { return m_inners; }
inline void clear()
{
m_outer.clear();
m_inners.clear();
}
This means that your *it (ie, a model::polygon) is limited to calling only those functions.
What it looks like you want to do is grab either the outer ring or one of the inner rings of each polygon in the vector (not sure which , inner or outer), and see if the range of whatever in that ring is greater than or equal to 2.
To do this, we must do some more mpl and typedef.
typedef boost::geometry::model::point<double, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree> > spherical_point; // your definition of a spherical_point
typedef boost::geometry::model::polygon<spherical_point> polygon; //consolidation of template args for a polygon
typedef boost::geometry::ring_type<polygon>::type ring_type; // define a ring_type that can handle your spherical_point by way of the polygon typedef.
typedef boost::geometry::interior_type<polygon>::type int_type; //define a interior_type that can handle your spherical_point
To complete this and just up and get it "working" I decided to assume you wanted the "outer" ring for your range limit conditional.
Here is, to me, compiling code, on gcc 4.1.1 with boost 1.48.
I leave whether the logic is correct up to someone else.
using namespace boost::geometry;
typedef boost::geometry::model::point<double, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree> > spherical_point;
typedef boost::geometry::model::polygon<spherical_point> polygon;
typedef boost::geometry::ring_type<polygon>::type ring_type;
typedef boost::geometry::interior_type<polygon>::type int_type;
class PointAggregator
{
private :
double *x, *y;
int count;
public :
PointAggregator(int size)
{
x = (double*) malloc(sizeof(double) * size);
y = (double*) malloc(sizeof(double) * size);
count = 0;
}
~PointAggregator()
{
free(x);
free(y);
}
inline void operator()(spherical_point& p)
{
x[count] = get<0>(p);
y[count] = get<1>(p);
count++;
}
void GetResult(double *resultX, double *resultY)
{
resultX = x;
resultY = y;
}
};
void VectorToArray(std::vector<model::polygon<spherical_point> > resultVector, double x[], double y[], int *count)
{
for (std::vector<model::polygon<spherical_point> >::iterator it = resultVector.begin(); it != resultVector.end(); ++it)
{
model::polygon<spherical_point> tmpPoly;
tmpPoly = (*it);
boost::geometry::ring_type<polygon>::type somering = tmpPoly.outer(); //typed it all out again instead of using ring_type since the complier was complaining and i didn't wanna get into it.
int ringsize = boost::size(somering);
if(ringsize >= 2)
{
*count = ringsize;
PointAggregator* pa = new PointAggregator(*count);
boost::geometry::for_each_point(*it, *pa);
pa->GetResult(x, y);
delete(pa);
break;
}
}
}
I found a few things that needed to be fixed:
One issue I see is in your templates. Be sure to put spaces!
boost range works on containers or ranges that hold begin, end pairs
Iterators represents something like a pointer to an object. Getting the size of the iterator will not do what you want. You need to either use boost::size of a whole container, or std::distance(begin_iterator,end_iterator).
Here is a version that compiles:
#include <vector>
#include <boost/range.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/polygon.hpp>
using namespace boost::geometry;
typedef boost::geometry::model::point
<
double, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree>
> spherical_point;
class PointAggregator {
private :
double *x, *y;
int count;
public :
PointAggregator(int size) {
x = (double*) malloc(sizeof(double) * size);
y = (double*) malloc(sizeof(double) * size);
count = 0;
}
~PointAggregator() {
free(x);
free(y);
}
inline void operator()(spherical_point& p) {
x[count] = get<0>(p);
y[count] = get<1>(p);
count++;
}
void GetResult(double *resultX, double *resultY) {
resultX = x;
resultY = y;
}
};
// added spaces to the close brackets >> becomes > >
void VectorToArray(std::vector<model::polygon<spherical_point> > resultVector, double x[], double y[], int *count) {
for (std::vector<model::polygon<spherical_point> >::iterator it = resultVector.begin(); it != resultVector.end(); ++it) {
if (boost::size(resultVector) >= 2) {
// getting the size of the whole container
*count = boost::size(resultVector);
PointAggregator* pa = new PointAggregator(*count);
boost::geometry::for_each_point(*it, *pa);
pa->GetResult(x, y);
delete(pa);
break;
}
}
}