Move Cephelepod into deprecated_compiler, create captian.sh to handle bootstrapping kraken from backup or from Cephelepod
This commit is contained in:
50
deprecated_compiler/include/RemovalTransformation.h
Normal file
50
deprecated_compiler/include/RemovalTransformation.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef REMOVALTRANSFORMATION_H
|
||||
#define REMOVALTRANSFORMATION_H
|
||||
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
#include "NodeTransformation.h"
|
||||
|
||||
template<class T>
|
||||
class RemovalTransformation: public NodeTransformation<T,T> {
|
||||
public:
|
||||
RemovalTransformation(T toRemove);
|
||||
~RemovalTransformation();
|
||||
virtual NodeTree<T>* transform(NodeTree<T>* from);
|
||||
|
||||
private:
|
||||
T toRemove;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
RemovalTransformation<T>::RemovalTransformation(T toRemove) {
|
||||
this->toRemove = toRemove;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
RemovalTransformation<T>::~RemovalTransformation() {
|
||||
//
|
||||
}
|
||||
|
||||
template<class T>
|
||||
NodeTree<T>* RemovalTransformation<T>::transform(NodeTree<T>* from) {
|
||||
std::queue<NodeTree<T>*> toProcess;
|
||||
toProcess.push(from);
|
||||
while(!toProcess.empty()) {
|
||||
NodeTree<T>* node = toProcess.front();
|
||||
toProcess.pop();
|
||||
if (!node)
|
||||
continue;
|
||||
std::vector<NodeTree<T>*> children = node->getChildren();
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
if (children[i]->getData() == toRemove)
|
||||
node->removeChild(children[i]);
|
||||
else if (children[i])
|
||||
toProcess.push(children[i]);
|
||||
}
|
||||
}
|
||||
return from;
|
||||
}
|
||||
Reference in New Issue
Block a user