Here's C++ code. I'm confused as to why dereferencing the iterator tells me the variable is read only? It's a public member of the Node class. What is my error?
adjTable is a set of Node elements -see declarations below.
Cells::iterator pos = adjTable.find(*thisNode);
if (pos == adjTable.end()) { // Did we find it?
NSLog(@"Not found");
// What to do here if node not found
}
// We found the node - mark it as grey in the table
(*pos).colour = grey; // <<<<<<<< this is the line with the issue
Here are the declarations etc.(it doesn't seem to format correctly)
class Node { // Define a single node a.k.a. matrix cell
public:
short nodeID; // the tag from the cell
short colour; // for tri-colour used in traversing
std::vector<short>adjs; // nodeIDs of adjacent nodes
// Ctors
Node(){};
Node(short ID, short col, std::vector<short>adjs)
: nodeID(ID), colour(col), adjs(adjs){}
// Dtors
~Node(){};
// operators
bool operator<(const Node& rhs) const{
return nodeID < rhs.nodeID;
}
bool operator==(const Node& rhs) const{
return nodeID == rhs.nodeID;
}
};
typedef std::set<Node,SortNodeSet> Cells;
class MakeTable {
public:
MakeTable(){};
~MakeTable(){};
Cells makeTable();
};