Skip to content
Snippets Groups Projects
Commit 34eec775 authored by Jan Trávníček's avatar Jan Trávníček Committed by Tomáš Pecka
Browse files

improve ext tree comparison

parent 1f554ac4
No related branches found
No related tags found
1 merge request!119Merge jt
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <extensions/compare.hpp> #include <extensions/compare.hpp>
#include <extensions/iterator.hpp> #include <extensions/iterator.hpp>
   
#include "tuple.hpp"
namespace ext { namespace ext {
   
/** /**
...@@ -1138,21 +1140,12 @@ public: ...@@ -1138,21 +1140,12 @@ public:
* positive if this instance is bigger than \p other instance * positive if this instance is bigger than \p other instance
*/ */
int compare ( const tree & other ) const { int compare ( const tree & other ) const {
static ext::compare < typename std::decay < T >::type > comp; auto first = ext::tie ( this->getData ( ), this->getChildren ( ) );
auto iterF = this->prefix_begin ( ); auto second = ext::tie ( other.getData ( ), other.getChildren ( ) );
auto iterS = other.prefix_begin ( );
for ( ; iterF != this->prefix_end ( ) || iterS != other.prefix_end ( ); ++iterF, ++iterS ) {
int res = comp ( * iterF, * iterS );
if ( res != 0 ) return res;
}
if ( iterF != this->prefix_end ( ) ) return -1;
   
if ( iterS != other.prefix_end ( ) ) return 1; static ext::compare < decltype ( first ) > comp;
   
return 0; return comp ( first, second );
} }
   
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment