how to traverse a pointer to set in c++?

Asked

Viewed 125 times

1

Hi, I’m implementing Kruskal’s algorithm, but I can’t navigate one set< No*>* to test the FIND_SET method, which is a set< No*>* how should I proceed? (in the rest of the code I walked set with foreach, as to set< No*>* I don’t know what to do);

static void Kruskal(Grafo* g) {

    vector<set<No*>> conjuntos;
    No* save;
    int zero = 0;
    for each (No* vertice in g->vetor)
    {

        set<No*> con =MAKE_SET(vertice);
        if (zero == 0) {
            save = vertice;
            zero = 1;


        }
        conjuntos.push_back(con);
        for each (No* var in con )
        {
            cout << var->nome << endl;
        }
    }

    vector <pair<pair<No*, No*>, double>> arestas;
    iniciar_arestas(arestas, g);
    ordenar_arestas(arestas);
    exibir_arestas(arestas);
    cout << endl << endl;

    set<No*>* conj = NULL;
        conj =(FIND_SET(save, conjuntos));

    if (conj != NULL) {

        //Aqui
        //quero exibir os membros de conj que eh um set*


    }
    else{
        cout << "false";
}

}

In this more specific section I want to do this:

set<No*>* conj = NULL;
    conj =(FIND_SET(save, conjuntos));

if (conj != NULL) {

    //Aqui
    //quero exibir os membros de conj que eh um set*


}
  • "for each" ??? That’s not C++...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.