void SetPredecessor(const Node &node, const Node &parent) { // Try to find the given node in the node_parent_map node_parent_iterator it = node_parents.find(node); if (it == node_parents.end()) // first entry // If the node wasn't found // -> Insert a new node into the node_parent_map node_parents.insert(std::make_pair(node, parent)); else // If the node was found // -> Replace the according parent node with the new one it->second = parent; }
/** * Find best predecessor found so far to the specified node * * @param n Node as destination to find best predecessor for * * @return Predecessor node */ gcc_pure Node GetPredecessor(const Node &node) const { // Try to find the given node in the node_parent_map node_parent_const_iterator it = node_parents.find(node); if (it == node_parents.end()) // first entry // If the node wasn't found // -> Return the given node itself return node; // If the node was found // -> Return the parent node return it->second; }
void SetPredecessor(const Node &node, const Node &parent) { // Try to find the given node in the node_parent_map auto result = node_parents.insert(std::make_pair(node, parent)); if (!result.second) // If the node was found // -> Replace the according parent node with the new one result.first->second = parent; }
/** Clears the queues */ void Clear() { // Clear the search queue q.clear(); // Clear the node_parent_map node_parents.clear(); // Clear the node_value_map node_values.clear(); }
/** Clears the queues */ void Clear() { // Clear the search queue while (!q.empty()) q.pop(); // Clear the node_parent_map node_parents.clear(); // Clear the node_value_map node_values.clear(); }