Inferno
0.2
|
00001 00002 #include "node/node.hpp" 00003 #include "common/common.hpp" 00004 00005 #ifndef SIMPLE_COMPARE_HPP 00006 #define SIMPLE_COMPARE_HPP 00007 00008 /** A subtree comparison algorithm that only operates on 00009 program nodes (not S&R patterns) and therefore can 00010 avoid O(n!) algorithms. */ 00011 class SimpleCompare 00012 { 00013 public: 00014 /// Pass in two pointers to nodes, which can point to subtrees. Result is true if they match. O(1) locally. 00015 bool operator()( TreePtr<Node> x, TreePtr<Node> y ); 00016 /// Pass in two sequences of pointers to nodes, which can point to subtrees. Result is true if they match. O(n) locally. 00017 bool operator()( SequenceInterface &x, SequenceInterface &y ); 00018 /// Pass in two collection of pointers to nodes, which can point to subtrees. Result is true if they match. O(n^2) locally. 00019 bool operator()( CollectionInterface &x, CollectionInterface &y ); 00020 }; 00021 00022 #endif