diff --git a/hurricane/src/hurricane/hurricane/Interval.h b/hurricane/src/hurricane/hurricane/Interval.h index 6a2d66a6..525237c3 100644 --- a/hurricane/src/hurricane/hurricane/Interval.h +++ b/hurricane/src/hurricane/hurricane/Interval.h @@ -1,6 +1,6 @@ // -*- C++ -*- // -// Copyright (c) BULL S.A. 2000-2018, All Rights Reserved +// Copyright (c) BULL S.A. 2000-2023, All Rights Reserved // // This file is part of Hurricane. // @@ -29,9 +29,7 @@ // +-----------------------------------------------------------------+ -#ifndef HURRICANE_INTERVAL_H -#define HURRICANE_INTERVAL_H - +#pragma once #include "hurricane/DbU.h" namespace Hurricane { @@ -48,6 +46,11 @@ namespace Hurricane { inline bool operator() ( const Interval& rhs, const Interval& lhs ) const; inline bool operator() ( const Interval* rhs, const Interval* lhs ) const; }; + class CompareByMinMax { + public: + inline bool operator() ( const Interval& rhs, const Interval& lhs ) const; + inline bool operator() ( const Interval* rhs, const Interval* lhs ) const; + }; public: Interval ( bool makeEmpty=true ); Interval ( const DbU::Unit& ); @@ -124,6 +127,20 @@ namespace Hurricane { { return lhs->getVMin() < rhs->getVMin(); } + inline bool Interval::CompareByMinMax::operator() ( const Interval& lhs, const Interval& rhs ) const + { + if (lhs.getVMin() != rhs.getVMin()) return lhs.getVMin() < rhs.getVMin(); + return lhs.getVMax() < rhs.getVMax(); + } + + + inline bool Interval::CompareByMinMax::operator() ( const Interval* lhs, const Interval* rhs ) const + { + if (lhs->getVMin() != rhs->getVMin()) return lhs->getVMin() < rhs->getVMin(); + return lhs->getVMax() < rhs->getVMax(); + } + + } // Hurricane namespace. @@ -136,7 +153,5 @@ inline void jsonWrite ( JsonWriter* w, const std::string& key, const Hurricane: w->endArray(); } + INSPECTOR_PR_SUPPORT(Hurricane::Interval); - - -#endif // HURRICANE_INTERVAL_H diff --git a/hurricane/src/hurricane/hurricane/IntervalTree.h b/hurricane/src/hurricane/hurricane/IntervalTree.h index f479651c..20c55536 100644 --- a/hurricane/src/hurricane/hurricane/IntervalTree.h +++ b/hurricane/src/hurricane/hurricane/IntervalTree.h @@ -1,6 +1,6 @@ // -*- C++ -*- // -// Copyright (c) BULL S.A. 2018-2018, All Rights Reserved +// Copyright (c) BULL S.A. 2018-2023, All Rights Reserved // // This file is part of Hurricane. // @@ -34,9 +34,7 @@ // Third edition, MIT press, 2011, p. 348. -#ifndef HURRICANE_INTERVAL_TREE_H -#define HURRICANE_INTERVAL_TREE_H - +#pragma once #include "hurricane/Interval.h" #include "hurricane/RbTree.h" @@ -117,14 +115,14 @@ namespace Hurricane { return record; } + // ------------------------------------------------------------------- // Class : "Hurricane::IntervalTree". - template< typename Data > - class IntervalTree : public RbTree< IntervalData, Interval::CompareByMin > { + class IntervalTree : public RbTree< IntervalData, Interval::CompareByMinMax > { public: - typedef RbTree< IntervalData, Interval::CompareByMin > Super; + typedef RbTree< IntervalData, Interval::CompareByMinMax > Super; public: class overlap_iterator : public Super::iterator { public: @@ -414,5 +412,3 @@ namespace Hurricane { } // HUrricane namespace. - -#endif // HURRICANE_INTERVAL_TREE_H diff --git a/hurricane/src/hurricane/hurricane/RbTree.h b/hurricane/src/hurricane/hurricane/RbTree.h index ef9d3cc2..d441540d 100644 --- a/hurricane/src/hurricane/hurricane/RbTree.h +++ b/hurricane/src/hurricane/hurricane/RbTree.h @@ -557,10 +557,10 @@ namespace Hurricane { Node* current = root_; while ( current ) { - cdebug_log(0,0) << "| " << current << std::endl; + cdebug_log(0,0) << "| " << current->getValue() << std::endl; if (current->getValue() == value) { - cdebug_log(0,-1) << "> Value found: " << current < Value found: " << current->getValue() <