Search code examples
c++algorithmvisual-c++path-finding

Error code = 0x80070002 (MS Visual Studio) C++ for searching triplet data from one key element


enter image description here

How finding a map triplet pair with one element for example (4,(?,?)) so i know that int 4 -> how can i find it because i get so much error and four hours of searching for possible solution to filter the coordinates with that key.

 int k = *min_element(min1.begin(), min1.end());

 auto it = myninja.begin(); 
 it = find(myninja.begin(), myninja.end(), k);
 for (it = myninja.begin(); it != myninja.end(); it++) {
     p.row= (it->second).first;
     p.col = (it->second).second;
 }

these are my declarations

vector <pair<int, pair<int, int> > > myninja; 
    vector <int> min1; 

and this is where i want to put out my min for A* -> f value for minimum range to goal

 int k = *min_element(min1.begin(), min1.end());

to keep the actual value from this i want to update the start point with the minimum of f -> so i want to give the point (x,y) so i thought

vector <pair<int, pair<int, int> > > myninja;

would be the best, but always i want to find out from which f(n) value it comes from -> error in iterator/loop or it displays me errorcode

i think i comes from the find function because maybe he can't handle a int k (which i want to search my points)

(F-Value,(x-coordinate,y-coordinate)

also this is not working

int k = *min_element(min1.begin(), min1.end());
auto result = std::find_if(myninja.begin(),myninja.end(),[k](const auto& mo){return mo.second == val; });

 //RETURN VARIABLE IF FOUND
  if (result != myninja.end())
  int foundkey = (result->second).first;

Solution

  •     int s = myninja.size();
        int j = min1.size(); 
          
        for (int i = 0; i < s; i++)
        {
        min1.push_back(myninja[i].first);
        }
        
        int mic = min1[0];
        
        for (int i = 0; i <j; i++)
         {
         if (min1[i] < mic)
         mic = min1[i];
         }
        
         cout << mic;
         
        for (int i = 0; i < s; i++)
        {
        if (myninja[i].first == mic) {
        
        // "first" and "second" are used to access 
        // 1st and 2nd element of pair respectively 
        
        p.row = myninja[i].second.first;
        p.col = myninja[i].second.second;
        
        q.push(objects(p.row, p.col, p.dist+1));
        
        cout << "Min Punkt";
        cout << " x " << p.row << " y " << p.col;
        
        cout << "Distanz"; 
        cout << p.dist;
        
        visit[p.row][p.col] = true;
        break;
    }      
    }
    

    // Finally it works but it saves now the same point again and again with the minimum of f. // i am working on to delete or set it true so after the calculation -> get the new point with other f minimum till the goal.