mercredi 29 juillet 2015

I am creating a program that scans and parses a text file, creates a database, and evaluates queries based on schemes and facts. My data structure is as follows:

Relation
    Scheme
    set<Tuple>

Where Scheme and Tuple inherit from std::vector<std::string>. The Scheme and every Tuple should have the same number of elements, and I repeatedly need to remove the values at a certain index in all three. For example, if I have:

Scheme
    C D H
Tuples
    EE200 F 10AM
    EE200 M 10AM
    EE200 W 1PM

organized so:

  C='EE200' D='F' H='10AM'
  C='EE200' D='M' H='10AM'
  C='EE200' D='W' H='1PM'

After removal at index 0 of every vector I should have:

  D='F' H='10AM'
  D='M' H='10AM'
  D='W' H='1PM'

I have written this code to localize the problem with an example. I first erase the index in the Scheme (which is essentially a vector of strings) and then loop through every Tuple in the set and attempt to remove the value at the index. In my example I forwent creating classes and instead just used std::string or std::vector<std::string>. The problem is here:

    for(set<vector<string>>::iterator t = tempTuples.begin(); t != tempTuples.end(); ++t)
    {
        // how do I erase the element at t?  
    }

Where tempTuples is the set of Tuple objects (here just vectors of strings). (*t).erase((*t).begin()) gives an error (no matching member function for call to 'erase') when inserted at this point. How do I remove the value at an index here?

Aucun commentaire:

Enregistrer un commentaire