TensorComprehensions
TensorComprehensions copied to clipboard
ScheduleTree: replace comparison operators with named functions
Proceeding with ScheduleTree evolution plan (#553)
This PR replaces overloaded comparison operators with two functions, nodeEquals and treeEquals. The main motivation for this change: after grafting ScheduleTreeElem* onto ScheduleTree in the inheritance structure we ended up with operator== comparing subtrees if called on ScheduleTree and nodes if called on instances of other classes. I argue that the behavior of default comparison operator is unintutitive for tree-like structure. Therefore, introducing explicitly-named comparison functions that make the intention clear is an improvement.
As an additional benefit, regular member functions can be declared virtual, unlike operators. With this approach, each subclass needs to override one abstract function that does node-to-node comparison while subtree comparison is handed automatically. Previously, it would have been necessary to also modify the clunky macro-based logic in one of the comparison operators.