Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 9db442ad authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add method to get the first node which is not updated (getIsUpdated() == false)

parent aaff3c36
Pipeline #130182 passed with stages
in 1 minute and 2 seconds
......@@ -9,6 +9,7 @@
#include <fstream>
#include <map>
#include <vector>
#include "Node.h"
///@brief Abstract Graph of Node
......@@ -46,10 +47,13 @@ class Graph{
void connectNode(UIdx parent, UIdx child);
void connectNode(UIdx parent, const std::list<UIdx> & listChildren);
void connectNode(UIdx parent, const std::vector<UIdx> & vecChildren);
const Node<T, UIdx> * getNode(UIdx index) const;
Node<T, UIdx> * getNode(UIdx index);
const Node<T, UIdx> * getFirstNotUpdatedNode() const;
Node<T, UIdx> * getFirstNotUpdatedNode();
bool isNodeExist(UIdx index) const;
......
......@@ -285,6 +285,23 @@ void Graph<T, UIdx>::connectNode(UIdx parent, const std::list<UIdx> & listChildr
}
}
///Connect a parent to its children
/** @param parent : index of the parent Node
* @param vecChildren : vector of the children index
*/
template<typename T, typename UIdx>
void Graph<T, UIdx>::connectNode(UIdx parent, const std::vector<UIdx> & vecChildren){
Node<T, UIdx> * parentNode = getNode(parent);
if(parentNode == NULL){return;}
for(typename std::vector<UIdx>::const_iterator it(vecChildren.begin()); it != vecChildren.end(); ++it){
UIdx child = *it;
Node<T, UIdx> * childNode = getNode(child);
if(childNode == NULL){continue;}
parentNode->addChild(child);
childNode->addParent(parent);
}
}
///Get a Node by pointer
/** @param index : index of the node to be used
* @return pointer to this Node or NULL if the Node does not exist
......@@ -313,6 +330,32 @@ Node<T, UIdx> * Graph<T, UIdx>::getNode(UIdx index){
}
}
///Get the first node which is not udpated (getIsUpdated() == false)
/** @return pointer to the first node which is not udpated or NULL if there is no
*/
template<typename T, typename UIdx>
const Node<T, UIdx> * Graph<T, UIdx>::getFirstNotUpdatedNode() const{
for(typename std::map<UIdx, Node<T, UIdx> >::const_iterator itNode(p_mapNode.begin()); itNode != p_mapNode.end(); ++itNode){
if(!itNode->second.getIsUpdated()){
return &(itNode->second);
}
}
return NULL;
}
///Get the first node which is not udpated (getIsUpdated() == false)
/** @return pointer to the first node which is not udpated or NULL if there is no
*/
template<typename T, typename UIdx>
Node<T, UIdx> * Graph<T, UIdx>::getFirstNotUpdatedNode(){
for(typename std::map<UIdx, Node<T, UIdx> >::iterator itNode(p_mapNode.begin()); itNode != p_mapNode.end(); ++itNode){
if(!itNode->second.getIsUpdated()){
return &(itNode->second);
}
}
return NULL;
}
///Say if the node at index does exit
/** @param index : index of the node to be searched
* @return true if the Node does exist, false otheriwse
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment