From: abv Date: Tue, 30 Jun 2015 07:47:45 +0000 (+0300) Subject: 0024859: Replace SortTools by STL equivalents X-Git-Tag: V7_0_0_beta~462 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=e35db4162b694d8f14d8d2e88e27ae189abd7210 0024859: Replace SortTools by STL equivalents Package SortTools and its derived classes are removed; STL sort algorithms are used instead. Comparator objects are mostly reimplemented as local classes. --- diff --git a/adm/UDLIST b/adm/UDLIST index 82e95ace8d..7ae7410a46 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -21,7 +21,6 @@ p Poly p Precision p Quantity p Resource -p SortTools p Standard p StdFail p Storage diff --git a/src/AppDef/AppDef_Variational.cxx b/src/AppDef/AppDef_Variational.cxx index 8962493fee..25a3184bae 100644 --- a/src/AppDef/AppDef_Variational.cxx +++ b/src/AppDef/AppDef_Variational.cxx @@ -53,9 +53,6 @@ #include #include -#include -#include -#include #include #include #include @@ -69,6 +66,9 @@ #include #include +// Add this line: +#include + #if defined(WNT) # include # include @@ -1152,8 +1152,6 @@ void AppDef_Variational::TheMotor( const Standard_Real BigValue = 1.e37, SmallValue = 1.e-6, SmallestValue = 1.e-9; - // SortTools_StraightInsertionSortOfReal Sort; - TCollection_CompareOfReal CompReal; Handle(TColStd_HArray1OfReal) CurrentTi, NewTi, OldTi; Handle(TColStd_HArray2OfInteger) Dependence; Standard_Boolean lestim, lconst, ToOptim, iscut; @@ -1294,8 +1292,9 @@ void AppDef_Variational::TheMotor( if (lestim && isnear) { // (1.7) Optimization of ti by ACR. - // Sort.Sort(CurrentTi->ChangeArray1(), CompReal); - SortTools_StraightInsertionSortOfReal::Sort(CurrentTi->ChangeArray1(), CompReal); + + std::stable_sort (CurrentTi->begin(), CurrentTi->end()); + Standard_Integer Decima = 4; CCurrent->Length(0., 1., CBLONG); @@ -1325,8 +1324,9 @@ void AppDef_Variational::TheMotor( OldTi->ChangeArray1() = CurrentTi->Array1(); // (2.2) Optimization des ti by ACR. - // Sort.Sort(CurrentTi->ChangeArray1(), CompReal); - SortTools_StraightInsertionSortOfReal::Sort(CurrentTi->ChangeArray1(), CompReal); + + std::stable_sort (CurrentTi->begin(), CurrentTi->end()); + Standard_Integer Decima = 4; CCurrent->Length(0., 1., CBLONG); @@ -1412,8 +1412,8 @@ void AppDef_Variational::TheMotor( // (3.2) On arrange les ti : Trie + recadrage sur (0,1) // ---> On trie, afin d'assurer l'ordre par la suite. - // Sort.Sort(CurrentTi->ChangeArray1(), CompReal); - SortTools_StraightInsertionSortOfReal::Sort(CurrentTi->ChangeArray1(), CompReal); + + std::stable_sort (CurrentTi->begin(), CurrentTi->end()); if ((CurrentTi->Value(1)!= 0.) || (CurrentTi->Value(NbrPnt)!= 1.)) { @@ -1912,11 +1912,7 @@ void AppDef_Variational::SplitCurve(const Handle(FEmTool_Curve)& InCurve, for(i = InKnots.Lower(); i <= InKnots.Upper(); i++) OutKnots(i) = InKnots(i); for(i = NbElmOld + 1; i <= NbElm; i++) OutKnots(i + i0) = NewKnots(i); - // SortTools_ShellSortOfReal Sort; - TCollection_CompareOfReal CompReal; - - // Sort.Sort(OutKnots, CompReal); - SortTools_ShellSortOfReal::Sort(OutKnots, CompReal); + std::sort (OutKnots.begin(), OutKnots.end()); } else iscut = Standard_False; diff --git a/src/BRepMesh/BRepMesh_FastDiscret.cxx b/src/BRepMesh/BRepMesh_FastDiscret.cxx index b9391a12df..f12c8312dc 100644 --- a/src/BRepMesh/BRepMesh_FastDiscret.cxx +++ b/src/BRepMesh/BRepMesh_FastDiscret.cxx @@ -50,8 +50,6 @@ #include #include #include -#include -#include #include #include diff --git a/src/BRepMesh/BRepMesh_FastDiscret.hxx b/src/BRepMesh/BRepMesh_FastDiscret.hxx index 67e4b9b454..22fc593d4f 100644 --- a/src/BRepMesh/BRepMesh_FastDiscret.hxx +++ b/src/BRepMesh/BRepMesh_FastDiscret.hxx @@ -48,8 +48,6 @@ class BRepMesh_Edge; class BRepMesh_Vertex; class gp_Pnt; class BRepMesh_FaceAttribute; -class TopTools_DataMapOfShapeReal; - //! Algorithm to mesh a shape with respect of the
//! frontier the deflection and by option the shared
diff --git a/src/BRepMesh/BRepMesh_FastDiscretFace.cxx b/src/BRepMesh/BRepMesh_FastDiscretFace.cxx index 4f54272a1c..4e443877ee 100644 --- a/src/BRepMesh/BRepMesh_FastDiscretFace.cxx +++ b/src/BRepMesh/BRepMesh_FastDiscretFace.cxx @@ -37,8 +37,6 @@ #include #include -#include -#include #include #include #include @@ -448,10 +446,9 @@ static void filterParameters(const BRepMesh::IMapOfReal& theParams, for (j = 1; j <= anInitLen; j++) aParamArray(j) = theParams(j); - TCollection_CompareOfReal aCompare; - SortTools_ShellSortOfReal::Sort(aParamArray, aCompare); + std::sort (aParamArray.begin(), aParamArray.end()); - // mandadory pre-filtering using the first (minimal) filter value + // mandatory pre-filtering using the first (minimal) filter value Standard_Real aP1, aP2; aP1 = aParamArray(1); aParamTmp.Append(aP1); diff --git a/src/Hermit/Hermit.cxx b/src/Hermit/Hermit.cxx index ea1607307f..4d82df2b4e 100644 --- a/src/Hermit/Hermit.cxx +++ b/src/Hermit/Hermit.cxx @@ -28,10 +28,10 @@ #include #include #include -#include -#include #include +#include + //======================================================================= //function : HermiteCoeff //purpose : calculate the Hermite coefficients of degree 3 from BS and @@ -175,8 +175,6 @@ static void PolyTest(const TColStd_Array1OfReal& Herm, Standard_Integer cas=0,mark=0,dercas=0, //loop marks min,max; //Pole min and max indices Standard_Real Us1,Us2,a; //bounderies value of the knots to be inserted -// gp_Pnt2d P ; - TCollection_CompareOfReal Comp; U4=0.0;U5=1.0; //default value if (Ux!=1.0){ @@ -215,7 +213,9 @@ static void PolyTest(const TColStd_Array1OfReal& Herm, TColStd_Array1OfReal knots(1,Knots->Length()); knots=Knots->ChangeArray1(); - SortTools_QuickSortOfReal::Sort(knots,Comp); //sort of the array of knots + + //sort of the array of knots + std::sort (knots.begin(), knots.end()); Polesinit(0).SetCoord(0.0,Herm(0)); //poles of the Hermite polynome in the BSpline form Polesinit(1).SetCoord(0.0,Herm(0)+Herm(1)/3.0); @@ -396,8 +396,6 @@ static void PolyTest(const TColStd_Array1OfReal& Herm, Standard_Integer cas=0,mark=0,dercas=0, //loop marks min,max; //Pole min and max indices Standard_Real Us1,Us2,a; //bounderies value of the knots to be inserted -// gp_Pnt2d P ; - TCollection_CompareOfReal Comp; U4=0.0;U5=1.0; //default value if (Ux!=1.0){ @@ -439,7 +437,9 @@ static void PolyTest(const TColStd_Array1OfReal& Herm, TColStd_Array1OfReal knots(1,Knots->Length()); knots=Knots->ChangeArray1(); - SortTools_QuickSortOfReal::Sort(knots,Comp); //sort of the array of knots + + //sort of the array of knots + std::sort (knots.begin(), knots.end()); Polesinit(0).SetCoord(0.0,Herm(0)); //poles of the Hermite polynome in the BSpline form Polesinit(1).SetCoord(0.0,Herm(0)+Herm(1)/3.0); diff --git a/src/IntTools/IntTools.cdl b/src/IntTools/IntTools.cdl index 10a805d02f..d6b03501f3 100644 --- a/src/IntTools/IntTools.cdl +++ b/src/IntTools/IntTools.cdl @@ -25,7 +25,6 @@ uses TColStd, BRepAdaptor, BRepTopAdaptor, - SortTools, TopTools, math, gp, @@ -54,8 +53,6 @@ is class Range; class CommonPrt; class Root; - class Compare; - class CompareRange; class EdgeEdge; @@ -115,18 +112,9 @@ is imported Array1OfRange; - class QuickSort instantiates - QuickSort from SortTools (Root from IntTools, - Array1OfRoots from IntTools, - Compare from IntTools); - - class QuickSortRange instantiates - QuickSort from SortTools (Range from IntTools, - Array1OfRange from IntTools, - CompareRange from IntTools); - imported SequenceOfCommonPrts; - - imported IndexedDataMapOfTransientAddress; + imported SequenceOfCommonPrts; + + imported IndexedDataMapOfTransientAddress; imported ListOfCurveRangeSample; diff --git a/src/IntTools/IntTools.cxx b/src/IntTools/IntTools.cxx index 793e170ff2..b6a60f924f 100644 --- a/src/IntTools/IntTools.cxx +++ b/src/IntTools/IntTools.cxx @@ -19,8 +19,6 @@ #include #include #include -#include -#include #include #include @@ -32,9 +30,8 @@ #include #include -#ifdef WNT -#pragma warning ( disable : 4101 ) -#endif +#include + //======================================================================= //function : IntTools::GetRadius //purpose : @@ -200,26 +197,33 @@ } } +//======================================================================= + +namespace { + // Auxiliary: comparator function for sorting roots + bool IntTools_RootComparator (const IntTools_Root& theLeft, const IntTools_Root& theRight) + { + return theLeft.Root() < theRight.Root(); + } +}; + //======================================================================= //function : SortRoots //purpose : //======================================================================= void IntTools::SortRoots(IntTools_SequenceOfRoots& mySequenceOfRoots, - const Standard_Real myEpsT) + const Standard_Real /*myEpsT*/) { Standard_Integer j, aNbRoots; aNbRoots=mySequenceOfRoots.Length(); - IntTools_Array1OfRoots anArray1OfRoots(1, aNbRoots); - IntTools_Compare aComparator(myEpsT); - + IntTools_Array1OfRoots anArray1OfRoots(1, aNbRoots); for (j=1; j<=aNbRoots; j++) { anArray1OfRoots(j)=mySequenceOfRoots(j); } - IntTools_QuickSort aQS; - aQS.Sort(anArray1OfRoots, aComparator); + std::sort (anArray1OfRoots.begin(), anArray1OfRoots.end(), IntTools_RootComparator); mySequenceOfRoots.Clear(); for (j=1; j<=aNbRoots; j++) { diff --git a/src/IntTools/IntTools_Compare.cdl b/src/IntTools/IntTools_Compare.cdl deleted file mode 100644 index efca7f5d3c..0000000000 --- a/src/IntTools/IntTools_Compare.cdl +++ /dev/null @@ -1,60 +0,0 @@ --- Created on: 2000-05-22 --- Created by: Peter KURNEV --- Copyright (c) 2000-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -class Compare from IntTools - - ---Purpose: Auxiliary class to provide a sorting Roots. - -uses - Root from IntTools - -is - Create - returns Compare from IntTools; - ---Purpose: - --- Empty constructor - --- - - Create (aTol:Real from Standard) - returns Compare from IntTools; - ---Purpose: - --- Initializes me by tolerance - --- - - IsLower (me; Left, Right: Root from IntTools) - ---Purpose: - --- Returns True if is lower than . - --- - returns Boolean from Standard; - - IsGreater (me; Left, Right: Root from IntTools) - ---Level: Public - ---Purpose: - --- Returns True if is greater than . - --- - returns Boolean from Standard; - - IsEqual(me; Left, Right: Root from IntTools) - ---Level: Public - ---Purpose: - --- Returns True when and are equal. - --- - returns Boolean from Standard ; - - -fields - myTol: Real from Standard; - -end Compare; diff --git a/src/IntTools/IntTools_Compare.cxx b/src/IntTools/IntTools_Compare.cxx deleted file mode 100644 index 67d2e00f7b..0000000000 --- a/src/IntTools/IntTools_Compare.cxx +++ /dev/null @@ -1,69 +0,0 @@ -// Created on: 2000-05-22 -// Created by: Peter KURNEV -// Copyright (c) 2000-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include -//======================================================================= -//function :IntTools_Compare::IntTools_Compare -//purpose : -//======================================================================= -IntTools_Compare::IntTools_Compare() :myTol(1.e-12) {} - -//======================================================================= -//function :IntTools_Compare::IntTools_Compare -//purpose : -//======================================================================= - IntTools_Compare::IntTools_Compare(const Standard_Real aTol) -{ - myTol=aTol; -} - -//======================================================================= -//function :IsLower -//purpose : -//======================================================================= - Standard_Boolean IntTools_Compare::IsLower(const IntTools_Root& aLeft, - const IntTools_Root& aRight)const -{ - return aLeft.Root() is lower than . - --- - returns Boolean from Standard; - - IsGreater (me; Left, Right: Range from IntTools) - ---Level: Public - ---Purpose: - --- Returns True if is greater than . - --- - returns Boolean from Standard; - - IsEqual(me; Left, Right: Range from IntTools) - ---Level: Public - ---Purpose: - --- Returns True when and are equal. - --- - returns Boolean from Standard ; - -fields - myTol: Real from Standard; - -end CompareRange; diff --git a/src/IntTools/IntTools_CompareRange.cxx b/src/IntTools/IntTools_CompareRange.cxx deleted file mode 100644 index 3147bd348e..0000000000 --- a/src/IntTools/IntTools_CompareRange.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// Created on: 2000-10-24 -// Created by: Peter KURNEV -// Copyright (c) 2000-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include -//======================================================================= -//function :IntTools_CompareRange::IntTools_CompareRange -//purpose : -//======================================================================= -IntTools_CompareRange::IntTools_CompareRange() :myTol(1.e-12) {} - -//======================================================================= -//function :IntTools_CompareRange::IntTools_CompareRange -//purpose : -//======================================================================= - IntTools_CompareRange::IntTools_CompareRange(const Standard_Real aTol) -{ - myTol=aTol; -} - -//======================================================================= -//function :IsLower -//purpose : -//======================================================================= - Standard_Boolean IntTools_CompareRange::IsLower(const IntTools_Range& aLeft, - const IntTools_Range& aRight)const -{ - return aLeft.First() #include #include -#include -#include #include #include #include @@ -64,9 +62,7 @@ #include #include -#ifdef WNT -#pragma warning ( disable : 4101 ) -#endif +#include static Standard_Boolean IsCoplanar (const BRepAdaptor_Curve& , @@ -604,6 +600,17 @@ void IntTools_EdgeFace::PrepareArgsFuncArrays(const Standard_Real ta, AddDerivativePoints(anArgs, aFunc); } + +//======================================================================= + +namespace { + // Auxiliary: comparator function for sorting ranges + bool IntTools_RangeComparator (const IntTools_Range& theLeft, const IntTools_Range& theRight) + { + return theLeft.First() < theRight.First(); + } +} + //======================================================================= //function : AddDerivativePoints //purpose : @@ -719,9 +726,7 @@ void IntTools_EdgeFace::AddDerivativePoints anArray1OfRange(n+i).SetLast (aFSeq(i)); } - IntTools_QuickSortRange aQuickSortRange; - IntTools_CompareRange aComparator; - aQuickSortRange.Sort (anArray1OfRange, aComparator); + std::sort (anArray1OfRange.begin(), anArray1OfRange.end(), IntTools_RangeComparator); // filling the output arrays myArgsArray.Resize(k); diff --git a/src/Resource/Resource.cdl b/src/Resource/Resource.cdl index 63d4aafb78..7860f73c86 100644 --- a/src/Resource/Resource.cdl +++ b/src/Resource/Resource.cdl @@ -23,7 +23,9 @@ package Resource -- initialize a variable. uses - TCollection,MMgt,SortTools,TColStd + TCollection, + MMgt, + TColStd is enumeration FormatType is @@ -47,11 +49,6 @@ is imported DataMapIteratorOfDataMapOfAsciiStringExtendedString; - class QuickSortOfArray1 instantiates - QuickSort from SortTools(AsciiString from TCollection, - Array1OfAsciiString from TColStd, - LexicalCompare from Resource) ; - ---Class: class LexicalCompare ; diff --git a/src/Resource/Resource_Manager.cxx b/src/Resource/Resource_Manager.cxx index d7142e40e5..6585761752 100644 --- a/src/Resource/Resource_Manager.cxx +++ b/src/Resource/Resource_Manager.cxx @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -30,6 +29,8 @@ #include +#include + #define END 0 #define EMPTY 1 #define COMMENT 2 @@ -286,8 +287,7 @@ Standard_Boolean Resource_Manager::Save() const for ( Index = 1; Iter.More(); Iter.Next()) KeyArray(Index++)= Iter.Key(); - Resource_LexicalCompare Comp; - Resource_QuickSortOfArray1::Sort(KeyArray, Comp); + std::sort (KeyArray.begin(), KeyArray.end()); TCollection_AsciiString Line, Value; for (Index = 1 ; Index <= NbKey ; Index++) { diff --git a/src/SelectMgr/FILES b/src/SelectMgr/FILES index c2321f7134..3c9296b2b8 100755 --- a/src/SelectMgr/FILES +++ b/src/SelectMgr/FILES @@ -1,4 +1,3 @@ -SelectMgr_CompareResults.hxx SelectMgr_FrustumBuilder.hxx SelectMgr_FrustumBuilder.cxx SelectMgr_IndexedMapOfOwner.hxx diff --git a/src/SelectMgr/SelectMgr.cdl b/src/SelectMgr/SelectMgr.cdl index 53f9b37d4d..a2b908ee45 100644 --- a/src/SelectMgr/SelectMgr.cdl +++ b/src/SelectMgr/SelectMgr.cdl @@ -247,7 +247,6 @@ is pointer SOPtr to SelectableObject from SelectMgr; - imported CompareResults; imported transient class IndexedMapOfOwner; imported SelectableObjectSet; imported FrustumBuilder; diff --git a/src/SelectMgr/SelectMgr_CompareResults.hxx b/src/SelectMgr/SelectMgr_CompareResults.hxx deleted file mode 100644 index a3b67a8acc..0000000000 --- a/src/SelectMgr/SelectMgr_CompareResults.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// Created on: 2003-10-23 -// Created by: Alexander GRIGORIEV -// Copyright (c) 2003-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include -#include -#include - -// Purpose: Redefine CompareOfInteger from TCollection, to be used -// in method SortResult from class ViewerSelector - -class SelectMgr_CompareResults: public TCollection_CompareOfInteger -{ - public: - SelectMgr_CompareResults - (const SelectMgr_IndexedDataMapOfOwnerCriterion& aMapOfCriterion) - : myMapOfCriterion (aMapOfCriterion) {} - Standard_Boolean IsLower - (const Standard_Integer&, const Standard_Integer&) const; - Standard_Boolean IsGreater - (const Standard_Integer&, const Standard_Integer&) const; - private: - const SelectMgr_IndexedDataMapOfOwnerCriterion& myMapOfCriterion; - void operator= (const SelectMgr_CompareResults& ); -}; - -//======================================================================= -//function : IsLower -//purpose : The sort order should be inverse (the greatest to come first) -//======================================================================= - -inline Standard_Boolean SelectMgr_CompareResults::IsLower - (const Standard_Integer &Left,const Standard_Integer &Right) const -{ - return (myMapOfCriterion.FindFromIndex(Left) > - myMapOfCriterion.FindFromIndex(Right)); -} - -//======================================================================= -//function : IsGreater -//purpose : The sort order should be inverse (the greatest to come first) -//======================================================================= - -inline Standard_Boolean SelectMgr_CompareResults::IsGreater - (const Standard_Integer &Left,const Standard_Integer &Right) const -{ - return (myMapOfCriterion.FindFromIndex(Left) < - myMapOfCriterion.FindFromIndex(Right)); -} diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index c8bb0903d4..5b41ac7aec 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -23,19 +23,42 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include #include +#include + +namespace { + // Comparison operator for sorting selection results + class CompareResults + { + public: + + CompareResults (const SelectMgr_IndexedDataMapOfOwnerCriterion& aMapOfCriterion) + : myMapOfCriterion (aMapOfCriterion) + { + } + + Standard_Boolean operator() (Standard_Integer theLeft, Standard_Integer theRight) const + { + return myMapOfCriterion.FindFromIndex(theLeft) > myMapOfCriterion.FindFromIndex(theRight); + } + + private: + void operator = (const CompareResults&); + + private: + const SelectMgr_IndexedDataMapOfOwnerCriterion& myMapOfCriterion; + }; +} //======================================================================= // function: SelectMgr_ToleranceMap @@ -687,8 +710,8 @@ void SelectMgr_ViewerSelector::SortResult() for (I=1; I <= anExtent; I++) thearr(I)=I; - SortTools_QuickSortOfInteger::Sort (thearr, - SelectMgr_CompareResults(mystored)); + std::sort (thearr.begin(), thearr.end(), CompareResults (mystored)); + } //======================================================================= diff --git a/src/SortTools/SortTools.cdl b/src/SortTools/SortTools.cdl deleted file mode 100644 index a4fe88df28..0000000000 --- a/src/SortTools/SortTools.cdl +++ /dev/null @@ -1,121 +0,0 @@ --- Created on: 1991-03-07 --- Created by: Herve Legrand --- Copyright (c) 1991-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - --- Revised: Fri Oct 30 1992 --- By : Mireille MERCIEN - - -package SortTools - - ---Purpose: This package provides the basic sorting tools generally - -- used. - -uses TCollection, - TColStd - -is - generic class HeapSort; - - generic class QuickSort; - - generic class ShellSort; - - generic class StraightInsertionSort; - - - -- The table below summarizes the most important characteristics that - -- must be considered when selecting a particular sorting algorithm. - -- A sorting algorithm is known as stable if the initial order of items - -- with equals keys is preserved after the sorting operation. - - ------------------------------------------------------------------------ - -- Algorithm Stable Comparisons Moves - -- Min Avg Max Min Avg Max - ------------------------------------------------------------------------ - -- 2 2 - -- QuickSort No nlogn nlogn n nlogn nlogn n - -- - ------------------------------------------------------------------------ - -- - -- HeapSort No nlogn nlogn nlogn nlogn nlogn nlogn - -- - ------------------------------------------------------------------------ - -- 1.25 1.25 - -- ShellSort No - n - - n - - -- - ------------------------------------------------------------------------ - -- 2 2 2 2 - -- StraightInsertion Yes n n n n n n - -- - ------------------------------------------------------------------------- - - --+ Heap sort exhibits an interesting time complexity, in that it runs - -- on the order of nlogn for the best, average, and worst case. - --+ Quick sort is still faster on the average(its constant of proportiona- - -- lity is lower), but it does not guarantee such good worst-case perfor- - -- mance. - --+ Shell sort is not sensitive to the initial ordering and offers accepta- - -- ble running time even for moderately larges arrays (say, 1000 elements). - --+ Insertion sort is the method of choice for "almost sorted" arrays with - -- few inversions : for such cases, it will outperform even the more - -- sophisticated method (quick sort, heap sort). - - --- Instantiations -- --- ************** -- ------------------------------------------------------------------------- - --- --- Instantiations QuickSort (Integer,Real) --- *************************************** - class QuickSortOfInteger instantiates QuickSort(Integer, - Array1OfInteger from TColStd, - CompareOfInteger from TCollection); - class QuickSortOfReal instantiates QuickSort(Real, - Array1OfReal from TColStd, - CompareOfReal from TCollection ); - --- Instantiations HeapSort (Integer,Real) --- *************************************** - class HeapSortOfInteger instantiates HeapSort(Integer, - Array1OfInteger from TColStd, - CompareOfInteger from TCollection); - class HeapSortOfReal instantiates HeapSort(Real, - Array1OfReal from TColStd, - CompareOfReal from TCollection); - --- Instantiations ShellSort (Integer,Real) --- *************************************** - class ShellSortOfInteger instantiates ShellSort(Integer, - Array1OfInteger from TColStd, - CompareOfInteger from TCollection); - class ShellSortOfReal instantiates ShellSort(Real, - Array1OfReal from TColStd, - CompareOfReal from TCollection ); - --- Instantiations StraightInsertionSort (Integer,Real) --- *************************************************** - class StraightInsertionSortOfInteger instantiates - StraightInsertionSort(Integer, - Array1OfInteger from TColStd, - CompareOfInteger from TCollection); - class StraightInsertionSortOfReal instantiates - StraightInsertionSort(Real, - Array1OfReal from TColStd, - CompareOfReal from TCollection); - -end SortTools; - diff --git a/src/SortTools/SortTools_HeapSort.cdl b/src/SortTools/SortTools_HeapSort.cdl deleted file mode 100644 index 5cf0620dcb..0000000000 --- a/src/SortTools/SortTools_HeapSort.cdl +++ /dev/null @@ -1,30 +0,0 @@ --- Created on: 1991-03-05 --- Created by: Herve Legrand --- Copyright (c) 1991-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -generic class HeapSort from SortTools (Item as any; - Array as Array1 from TCollection(Item); - Comparator as any) - - ---Purpose: This class provides the HeapSort algorithm. - -is - - Sort(myclass; TheArray : in out Array; Comp : Comparator); - ---Purpose: Sort an array using the HeapSort algorithm. - ---Level: Public - -end; - diff --git a/src/SortTools/SortTools_HeapSort.gxx b/src/SortTools/SortTools_HeapSort.gxx deleted file mode 100644 index 82b6e2c415..0000000000 --- a/src/SortTools/SortTools_HeapSort.gxx +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// SortTools_HeapSort.gxx -// cree le 04/11/91 par ASI -// Reference : Software Conponents with ADA, Grady Booch. - -void Shift(Array& TheArray, - const Comparator& Comp, - const Standard_Integer Left, const Standard_Integer Right) -{ - Item Temp = TheArray(Left); - Standard_Integer Front = Left; - Standard_Integer Back = Front * 2; - while (Back <= Right) { - if (Back < Right) { - if(Comp.IsLower(TheArray(Back), TheArray(Back + 1))) { - Back = Back + 1; - } - } - if(!Comp.IsLower(Temp, TheArray(Back))) break; - TheArray(Front) = TheArray(Back); - Front = Back; - if(Front * 2 > TheArray.Upper()) break; - Back = Front * 2; - } - TheArray(Front) = Temp; -} - -void SortTools_HeapSort::Sort(Array& TheArray, - const Comparator& Comp) -{ - Item TempItem; - Standard_Integer Left; - Standard_Integer Right; - - Left = ((TheArray.Upper() - TheArray.Lower() + 1) / 2) + 1; - Right = TheArray.Upper(); - while (Left > TheArray.Lower()) { - Left = Left - 1; - Shift(TheArray, Comp, Left, Right); - } - while (Right > TheArray.Lower()) { - TempItem = TheArray(TheArray.Lower()); - TheArray(TheArray.Lower()) = TheArray(Right); - TheArray(Right) = TempItem; - Right = Right - 1; - Shift(TheArray, Comp, Left, Right); - } -} - - - - - diff --git a/src/SortTools/SortTools_QuickSort.cdl b/src/SortTools/SortTools_QuickSort.cdl deleted file mode 100644 index 0f4bd4862c..0000000000 --- a/src/SortTools/SortTools_QuickSort.cdl +++ /dev/null @@ -1,30 +0,0 @@ --- Created on: 1991-03-05 --- Created by: Herve Legrand, Mireille MERCIEN --- Copyright (c) 1991-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -generic class QuickSort from SortTools (Item as any; - Array as Array1 from TCollection(Item); - Comparator as any) - - ---Purpose: This class provides the QuickSort algorithm. - -is - - Sort(myclass; TheArray : in out Array; Comp : Comparator); - ---Purpose: Sort an array using the QuickSort algorithm. - ---Level: Public - -end; - diff --git a/src/SortTools/SortTools_QuickSort.gxx b/src/SortTools/SortTools_QuickSort.gxx deleted file mode 100644 index 8c1d927bb7..0000000000 --- a/src/SortTools/SortTools_QuickSort.gxx +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// SortTools_QuickSort.gxx -// cree le 04/11/91 par ASI -// Reference : Software Conponents with ADA, Grady Booch. - -inline void Exchange(Item& Left, Item& Right) -{ - Item Temp = Left; - Left = Right; - Right = Temp; -} - -static void SortRecursive(Array& TheArray, - const Comparator& Comp, - const Standard_Integer Left, - const Standard_Integer Right) -{ - Item Pivot; - Standard_Integer Front, Back, Middle; - - if(Left < Right) { - Middle = (Left + Right) / 2; - if(Comp.IsLower(TheArray(Middle), TheArray(Left))) { - Exchange(TheArray(Middle), TheArray(Left)); - } - if(Comp.IsLower(TheArray(Right), TheArray(Left))) { - Exchange(TheArray(Right), TheArray(Left)); - } - if(Comp.IsLower(TheArray(Right), TheArray(Middle))) { - Exchange(TheArray(Right), TheArray(Middle)); - } - Pivot = TheArray(Middle); - Exchange(TheArray(Middle), TheArray(Right - 1)); - Front = Left + 1; - Back = Right - 1; - if(Back != TheArray.Lower()) { - Back = Back - 1; - } - for(;;) { - while (Comp.IsLower(TheArray(Front), Pivot)) { - Front = Front + 1; - } - while (Comp.IsLower(Pivot, TheArray(Back))) { - Back = Back - 1; - } - if(Front <= Back) { - if(Front == TheArray.Upper()) return; - if(Back == TheArray.Lower()) return; - Exchange(TheArray(Front), TheArray(Back)); - Front = Front + 1; - Back = Back - 1; - } - if(Front > Back) break; - } - SortRecursive(TheArray, Comp, Left, Back); - SortRecursive(TheArray, Comp, Front, Right); - } -} - -void SortTools_QuickSort::Sort(Array& TheArray, - const Comparator& Comp) -{ - SortRecursive(TheArray, Comp, TheArray.Lower(), TheArray.Upper()); -} - - - - - diff --git a/src/SortTools/SortTools_ShellSort.cdl b/src/SortTools/SortTools_ShellSort.cdl deleted file mode 100644 index 14757a726c..0000000000 --- a/src/SortTools/SortTools_ShellSort.cdl +++ /dev/null @@ -1,29 +0,0 @@ --- Created on: 1991-03-05 --- Created by: Herve Legrand,Mireille MERCIEN --- Copyright (c) 1991-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -generic class ShellSort from SortTools (Item as any; - Array as Array1 from TCollection(Item); - Comparator as any) - - ---Purpose: This class provides the ShellSort algorithm. - -is - - Sort(myclass; TheArray : in out Array; Comp : Comparator); - ---Purpose: Sort an array using the ShellSort algorithm. - ---Level: Public - -end; diff --git a/src/SortTools/SortTools_ShellSort.gxx b/src/SortTools/SortTools_ShellSort.gxx deleted file mode 100644 index 2a201882e0..0000000000 --- a/src/SortTools/SortTools_ShellSort.gxx +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// SortTools_ShellSort.gxx -// cree le 04/11/91 par ASI -// Reference : Software Conponents with ADA, Grady Booch. - -void SortTools_ShellSort::Sort(Array& TheArray, - const Comparator& Comp) -{ - - Item TempItem; - Standard_Integer Outer; - Standard_Integer Inner; - Standard_Integer Inc = 1; - - for(;;) { - if((9 * Inc) + 4 >= TheArray.Upper() - TheArray.Lower() + 1) break; - Inc = (Inc * 3) + 1; - } - for(;;) { - Outer = TheArray.Lower() + Inc; - for(;;) { - TempItem = TheArray(Outer); - Inner = Outer; - while (Comp.IsLower(TempItem, TheArray(Inner - Inc))) { - TheArray(Inner) = TheArray(Inner - Inc); - Inner = Inner - Inc; - if(Inner - Inc < TheArray.Lower()) break; - } - TheArray(Inner) = TempItem; - if(Outer + Inc > TheArray.Upper()) break; - Outer = Outer + Inc; - } - if(Inc == 1) break; - Inc = (Inc - 1) / 3; - } -} - - - - - diff --git a/src/SortTools/SortTools_StraightInsertionSort.cdl b/src/SortTools/SortTools_StraightInsertionSort.cdl deleted file mode 100644 index 2dec874c15..0000000000 --- a/src/SortTools/SortTools_StraightInsertionSort.cdl +++ /dev/null @@ -1,30 +0,0 @@ --- Created on: 1991-03-05 --- Created by: Herve Legrand, Mireille MERCIEN --- Copyright (c) 1991-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -generic class StraightInsertionSort from SortTools ( - Item as any; - Array as Array1 from TCollection(Item); - Comparator as any) - - ---Purpose: This class provides the StraightInsertionSort algorithm. - -is - - Sort(myclass; TheArray : in out Array; Comp : Comparator); - ---Purpose: Sort an array using the StraightInsertionSort algorithm. - ---Level: Public - -end; diff --git a/src/SortTools/SortTools_StraightInsertionSort.gxx b/src/SortTools/SortTools_StraightInsertionSort.gxx deleted file mode 100644 index 306f95c046..0000000000 --- a/src/SortTools/SortTools_StraightInsertionSort.gxx +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// SortTools_StraightInsertionSort.gxx -// cree le 04/11/91 par ASI -// Reference : Software Conponents with ADA, Grady Booch. - -void SortTools_StraightInsertionSort::Sort(Array& TheArray, - const Comparator& Comp) -{ - Item TempItem; - Standard_Integer J; - - for(Standard_Integer I = TheArray.Lower() + 1; I <= TheArray.Upper(); I++) { - TempItem = TheArray(I); - J = I; - while (Comp.IsLower(TempItem, TheArray(J - 1))) { - TheArray(J) = TheArray(J - 1); - J = J - 1; - if (J == TheArray.Lower()) break; - } - TheArray(J) = TempItem; - } -} - - - - - diff --git a/src/TCollection/FILES b/src/TCollection/FILES index f9cd00c519..b6ae69b640 100755 --- a/src/TCollection/FILES +++ b/src/TCollection/FILES @@ -1,3 +1 @@ -TCollection_Compare.gxx -TCollection_CMPLRS.edl TCollection_WOKSteps.edl diff --git a/src/TCollection/TCollection.cdl b/src/TCollection/TCollection.cdl index cfb3b975dd..55d1d121ad 100644 --- a/src/TCollection/TCollection.cdl +++ b/src/TCollection/TCollection.cdl @@ -79,19 +79,6 @@ is enumeration Side is Left , Right; - deferred generic class Compare ; - - private deferred class PrivCompareOfInteger - instantiates Compare from TCollection(Integer from Standard); - - private deferred class PrivCompareOfReal - instantiates Compare from TCollection(Real from Standard); - - class CompareOfInteger; - - class CompareOfReal; - - NextPrimeForMap(I : Integer) returns Integer; ---Purpose: Returns a prime number greater than suitable -- to dimension a Map. When becomes great there diff --git a/src/TCollection/TCollection_CMPLRS.edl b/src/TCollection/TCollection_CMPLRS.edl deleted file mode 100644 index 9c2234cde5..0000000000 --- a/src/TCollection/TCollection_CMPLRS.edl +++ /dev/null @@ -1,36 +0,0 @@ --- Created on: 1998-02-20 --- Created by: euclid --- Copyright (c) 1998-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -@if ( %DebugMode == "False" ) then - - @if ( %Station == "sun" ) then - @set %CMPLRS_CXX_ModeOpt = " -O3 -DNo_Exception "; - @endif; - - @if ( %Station == "ao1" ) then - @string %CMPLRS_CXX_ModeOpt += " -O3 -DNo_Exception "; - @endif; - - @if ( %Station == "sil" ) then - @set %CMPLRS_CXX_ModeOpt = " -O2 -DNo_Exception "; - @endif; - - @if ( %Station == "hp" ) then - @set %CMPLRS_CXX_ModeOpt = " +O3 -DNo_Exception "; - @endif; - -@endif; - diff --git a/src/TCollection/TCollection_Compare.cdl b/src/TCollection/TCollection_Compare.cdl deleted file mode 100644 index def3e20c28..0000000000 --- a/src/TCollection/TCollection_Compare.cdl +++ /dev/null @@ -1,49 +0,0 @@ --- Created on: 1991-05-14 --- Created by: Annick PANCHER --- Copyright (c) 1991-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - --- Revised: Mireille MERCIEN - - -deferred generic class Compare from TCollection ( Item as any ) - - ---Purpose: Defines a comparison operator which can be used by - -- any ordered structure. The way to compare items - -- has to be described in subclasses, which inherit - -- from instantiations of Compare. - -is - - IsLower (me; Left, Right: Item) - ---Level: Public - ---Purpose: returns True if is lower than . - returns Boolean - is virtual; - - IsGreater (me; Left, Right: Item) - ---Level: Public - ---Purpose: returns True if is greater than . - returns Boolean - is virtual; - - IsEqual(me; Left, Right: Item) - ---Level: Public - ---Purpose: returns True when and are equal. - returns Boolean - is virtual; - -end; - - diff --git a/src/TCollection/TCollection_Compare.gxx b/src/TCollection/TCollection_Compare.gxx deleted file mode 100644 index f710f55042..0000000000 --- a/src/TCollection/TCollection_Compare.gxx +++ /dev/null @@ -1,49 +0,0 @@ -// Created on: 1992-08-27 -// Created by: Mireille MERCIEN -// Copyright (c) 1992-1999 Matra Datavision -// Copyright (c) 1992-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -// ----------- -// IsLower : -// ----------- -Standard_Boolean TCollection_Compare::IsLower (const Item& , - const Item& ) const -{ - Standard_NotImplemented::Raise(); - return Standard_False; -} - -// ----------- -// IsGreater : -// ----------- -Standard_Boolean TCollection_Compare::IsGreater (const Item& , - const Item& ) const -{ - Standard_NotImplemented::Raise(); - return Standard_False; -} - -// ----------- -// IsEqual : -// ----------- -Standard_Boolean TCollection_Compare::IsEqual (const Item& Left, - const Item& Right) const -{ - return (Left == Right) ; -} - - diff --git a/src/TCollection/TCollection_CompareOfInteger.cdl b/src/TCollection/TCollection_CompareOfInteger.cdl deleted file mode 100644 index b31067e77b..0000000000 --- a/src/TCollection/TCollection_CompareOfInteger.cdl +++ /dev/null @@ -1,37 +0,0 @@ --- Created on: 1992-08-27 --- Created by: Mireille MERCIEN --- Copyright (c) 1992-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -class CompareOfInteger from TCollection - inherits - PrivCompareOfInteger - -is - - Create ; - - IsLower (me; Left, Right: Integer) - ---Level: Public - ---Purpose: Returns True if is lower than . - returns Boolean - is redefined; - - IsGreater (me; Left, Right: Integer) - ---Level: Public - ---Purpose: Returns True if is greater than . - returns Boolean - is redefined; - -end; diff --git a/src/TCollection/TCollection_CompareOfInteger.cxx b/src/TCollection/TCollection_CompareOfInteger.cxx deleted file mode 100644 index b1e11b83dc..0000000000 --- a/src/TCollection/TCollection_CompareOfInteger.cxx +++ /dev/null @@ -1,42 +0,0 @@ -// Created on: 1992-08-27 -// Created by: Mireille MERCIEN -// Copyright (c) 1992-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -// ----------- -// Create : -// ----------- -TCollection_CompareOfInteger::TCollection_CompareOfInteger() -{ -} - -// ----------- -// IsLower : -// ----------- -Standard_Boolean TCollection_CompareOfInteger::IsLower ( - const Standard_Integer &Left,const Standard_Integer &Right) const -{ - return (Left < Right) ; -} - -// ----------- -// IsGreater : -// ----------- -Standard_Boolean TCollection_CompareOfInteger::IsGreater ( - const Standard_Integer &Left,const Standard_Integer &Right) const -{ - return (Left > Right) ; -} diff --git a/src/TCollection/TCollection_CompareOfReal.cdl b/src/TCollection/TCollection_CompareOfReal.cdl deleted file mode 100644 index 0da832a2b3..0000000000 --- a/src/TCollection/TCollection_CompareOfReal.cdl +++ /dev/null @@ -1,37 +0,0 @@ --- Created on: 1992-08-27 --- Created by: Mireille MERCIEN --- Copyright (c) 1992-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -class CompareOfReal from TCollection - inherits - PrivCompareOfReal - -is - - Create; - - IsLower (me; Left, Right: Real) - ---Level: Public - ---Purpose: Returns True if is lower than . - returns Boolean - is redefined; - - IsGreater (me; Left, Right: Real) - ---Level: Public - ---Purpose: Returns True if is greater than . - returns Boolean - is redefined; - -end; diff --git a/src/TCollection/TCollection_CompareOfReal.cxx b/src/TCollection/TCollection_CompareOfReal.cxx deleted file mode 100644 index c2740e1bfd..0000000000 --- a/src/TCollection/TCollection_CompareOfReal.cxx +++ /dev/null @@ -1,47 +0,0 @@ -// Created on: 1992-08-27 -// Created by: Mireille MERCIEN -// Copyright (c) 1992-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -// ----------- -// Create : -// ----------- -TCollection_CompareOfReal::TCollection_CompareOfReal() -{ -} - -// ----------- -// IsLower : -// ----------- -Standard_Boolean TCollection_CompareOfReal::IsLower ( - const Standard_Real &Left,const Standard_Real &Right) const -{ - return (Left < Right) ; -} - -// ----------- -// IsGreater : -// ----------- -Standard_Boolean TCollection_CompareOfReal::IsGreater ( - const Standard_Real &Left,const Standard_Real &Right) const -{ - return (Left > Right) ; -} - - - - - diff --git a/src/TKernel/PACKAGES b/src/TKernel/PACKAGES index 0cb3325f20..501e8c4357 100755 --- a/src/TKernel/PACKAGES +++ b/src/TKernel/PACKAGES @@ -4,7 +4,6 @@ OSD Plugin Quantity Resource -SortTools Standard StdFail Storage diff --git a/src/math/FILES b/src/math/FILES index 52cff0edba..d688372bcd 100755 --- a/src/math/FILES +++ b/src/math/FILES @@ -15,3 +15,4 @@ math_BullardGenerator.hxx math_PSOParticlesPool.hxx math_PSOParticlesPool.cxx math_Array1OfValueAndWeight.hxx +math_ValueAndWeight.hxx diff --git a/src/math/math.cdl b/src/math/math.cdl index 9586654a39..cddb4f0e50 100644 --- a/src/math/math.cdl +++ b/src/math/math.cdl @@ -20,7 +20,7 @@ package math -uses StdFail, TColStd, TCollection, Standard, SortTools +uses StdFail, TColStd, TCollection, Standard is @@ -86,13 +86,8 @@ is class EigenValuesSearcher; -- for Kronrod method class ComputeGaussPointsAndWeights; class ComputeKronrodPointsAndWeights; - class ValueAndWeight; + imported ValueAndWeight; imported Array1OfValueAndWeight; - class CompareOfValueAndWeight; - class QuickSortOfValueAndWeight - instantiates QuickSort from SortTools (ValueAndWeight from math, - Array1OfValueAndWeight from math, - CompareOfValueAndWeight from math); class DoubleTab; diff --git a/src/math/math_CompareOfValueAndWeight.cdl b/src/math/math_CompareOfValueAndWeight.cdl deleted file mode 100644 index 6e0f07baf0..0000000000 --- a/src/math/math_CompareOfValueAndWeight.cdl +++ /dev/null @@ -1,41 +0,0 @@ --- Created on: 2005-12-20 --- Created by: Julia GERASIMOVA --- Copyright (c) 2005-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -class CompareOfValueAndWeight from math - -uses - - ValueAndWeight from math - -is - Create; - - IsLower (me; Left, Right: ValueAndWeight) - ---Level: Public - ---Purpose: Returns True if is lower than . - returns Boolean from Standard; - - IsGreater (me; Left, Right: ValueAndWeight) - ---Level: Public - ---Purpose: Returns True if is greater than . - returns Boolean from Standard; - - IsEqual(me; Left, Right: ValueAndWeight) - ---Level: Public - ---Purpose: returns True when and are equal. - returns Boolean from Standard; - -end; - diff --git a/src/math/math_CompareOfValueAndWeight.cxx b/src/math/math_CompareOfValueAndWeight.cxx deleted file mode 100644 index 4c2836c941..0000000000 --- a/src/math/math_CompareOfValueAndWeight.cxx +++ /dev/null @@ -1,50 +0,0 @@ -// Created on: 2005-12-20 -// Created by: Julia GERASIMOVA -// Copyright (c) 2005-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -// ----------- -// Create : -// ----------- -math_CompareOfValueAndWeight::math_CompareOfValueAndWeight() -{ -} - -// ----------- -// IsLower : -// ----------- -Standard_Boolean math_CompareOfValueAndWeight::IsLower(const math_ValueAndWeight& Left, - const math_ValueAndWeight& Right) const -{ - return (Left.Value() < Right.Value()); -} - -// ----------- -// IsGreater : -// ----------- -Standard_Boolean math_CompareOfValueAndWeight::IsGreater(const math_ValueAndWeight& Left, - const math_ValueAndWeight& Right) const -{ - return (Left.Value() > Right.Value()); -} - -// ----------- -// IsEqual : -// ----------- -Standard_Boolean math_CompareOfValueAndWeight::IsEqual(const math_ValueAndWeight& Left, - const math_ValueAndWeight& Right) const -{ - return (Left.Value() == Right.Value()); -} diff --git a/src/math/math_ComputeGaussPointsAndWeights.cxx b/src/math/math_ComputeGaussPointsAndWeights.cxx index 8ee76c8bf0..0744e6c489 100644 --- a/src/math/math_ComputeGaussPointsAndWeights.cxx +++ b/src/math/math_ComputeGaussPointsAndWeights.cxx @@ -17,10 +17,10 @@ #include #include -#include -#include #include +#include + math_ComputeGaussPointsAndWeights::math_ComputeGaussPointsAndWeights(const Standard_Integer Number) { myIsDone = Standard_False; @@ -62,8 +62,7 @@ math_ComputeGaussPointsAndWeights::math_ComputeGaussPointsAndWeights(const Stand VWarray(i) = EVW; } - math_CompareOfValueAndWeight theComparator; - math_QuickSortOfValueAndWeight::Sort(VWarray, theComparator); + std::sort (VWarray.begin(), VWarray.end()); for (i = 1; i <= Number; i++) { myPoints->ChangeValue(i) = VWarray(i).Value(); diff --git a/src/math/math_ComputeKronrodPointsAndWeights.cxx b/src/math/math_ComputeKronrodPointsAndWeights.cxx index 4bd6af94dc..59d5af880a 100644 --- a/src/math/math_ComputeKronrodPointsAndWeights.cxx +++ b/src/math/math_ComputeKronrodPointsAndWeights.cxx @@ -16,10 +16,10 @@ #include #include #include -#include -#include #include +#include + math_ComputeKronrodPointsAndWeights::math_ComputeKronrodPointsAndWeights(const Standard_Integer Number) { myIsDone = Standard_False; @@ -154,8 +154,7 @@ math_ComputeKronrodPointsAndWeights::math_ComputeKronrodPointsAndWeights(const S VWarray(i) = EVW; } - math_CompareOfValueAndWeight theComparator; - math_QuickSortOfValueAndWeight::Sort(VWarray, theComparator); + std::sort (VWarray.begin(), VWarray.end()); for (i = 1; i <= a2NP1; i++) { myPoints->ChangeValue(i) = VWarray(i).Value(); diff --git a/src/math/math_ValueAndWeight.cdl b/src/math/math_ValueAndWeight.cdl deleted file mode 100644 index 0bd620f970..0000000000 --- a/src/math/math_ValueAndWeight.cdl +++ /dev/null @@ -1,37 +0,0 @@ --- Created on: 2005-12-20 --- Created by: Julia GERASIMOVA --- Copyright (c) 2005-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -class ValueAndWeight from math - -is - Create - returns ValueAndWeight; - - Create(Value : Real from Standard; - Weight : Real from Standard) - returns ValueAndWeight; - - Value(me) - returns Real from Standard; - - Weight(me) - returns Real from Standard; - -fields - - myValue : Real from Standard; - myWeight : Real from Standard; - -end ValueAndWeight; diff --git a/src/math/math_ValueAndWeight.cxx b/src/math/math_ValueAndWeight.cxx deleted file mode 100644 index f79201305b..0000000000 --- a/src/math/math_ValueAndWeight.cxx +++ /dev/null @@ -1,37 +0,0 @@ -// Created on: 2005-12-20 -// Created by: Julia GERASIMOVA -// Copyright (c) 2005-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -math_ValueAndWeight::math_ValueAndWeight() -{ -} - -math_ValueAndWeight::math_ValueAndWeight(const Standard_Real Value, - const Standard_Real Weight) - : myValue(Value), - myWeight(Weight) -{ -} - -Standard_Real math_ValueAndWeight::Value() const -{ - return myValue; -} - -Standard_Real math_ValueAndWeight::Weight() const -{ - return myWeight; -} diff --git a/src/math/math_ValueAndWeight.hxx b/src/math/math_ValueAndWeight.hxx new file mode 100644 index 0000000000..b2c2b452d5 --- /dev/null +++ b/src/math/math_ValueAndWeight.hxx @@ -0,0 +1,55 @@ +// Created on: 2005-12-20 +// Created by: Julia GERASIMOVA +// Copyright (c) 2005-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _math_ValueAndWeight_HeaderFile +#define _math_ValueAndWeight_HeaderFile + +#include +#include +#include + +#include + +//! Simple container storing two reals: value and weight +class math_ValueAndWeight +{ +public: + + DEFINE_STANDARD_ALLOC + + math_ValueAndWeight () : myValue(0.), myWeight(0.) {} + + math_ValueAndWeight (Standard_Real theValue, Standard_Real theWeight) + : myValue(theValue), myWeight(theWeight) + {} + + Standard_Real Value() const { return myValue; } + + Standard_Real Weight() const { return myWeight; } + + +private: + Standard_Real myValue; + Standard_Real myWeight; +}; + +//! Comparison operator for math_ValueAndWeight, needed for sorting algorithms +inline bool operator < (const math_ValueAndWeight& theLeft, + const math_ValueAndWeight& theRight) +{ + return theLeft.Value() < theRight.Value(); +} + +#endif // _math_ValueAndWeight_HeaderFile