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 @@
#include <extensions/compare.hpp>
#include <extensions/iterator.hpp>
 
#include "tuple.hpp"
namespace ext {
 
/**
......@@ -1138,21 +1140,12 @@ public:
* positive if this instance is bigger than \p other instance
*/
int compare ( const tree & other ) const {
static ext::compare < typename std::decay < T >::type > comp;
auto iterF = this->prefix_begin ( );
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;
auto first = ext::tie ( this->getData ( ), this->getChildren ( ) );
auto second = ext::tie ( other.getData ( ), other.getChildren ( ) );
 
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