That's related to some exercise I am trying to do, so my question is specific about iterators: i have a set of data structure that i created (std::set<SomeClass> mySet
) and this set have 3 arguments: (int i, int j, ClassA a).
I am want to search based on i, j if something exists, but i do not have the "ClassA a".
And std::set::find - demand me the third key as well.
Is there a way to do that? I mean, without making a custom iterator.
The relevant codes part:
The data structure: (NB is another class that created)
class Cell {
public:
Cell(const int i, const int j, NB nb) : m_i(i), m_j(j), m_nb(nb) {}
bool operator<(const Cell& x)
{
if((this->m_i) < (x.m_i)) return true;
else if((this->m_i) > (x.m_i)) return false;
else return(this->m_j <= x.m_j);
}
private:
const int m_i;
const int m_j;
NB m_nb;
};
The function:
bool Board::legalPath(const vector<pair<int, int>> &path) const {
//set<Cell>::const_iterator ie = m_board.begin(); //is that even needed?
for(auto &x : path)
{
int i = x.first;
int j = x.second; //now have i, j - how can I see its exist in my set?
}
return true;
}
Thanks.