mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0033370: Foundation Classes - Moving into STL and Boost functionality
NCollection containers update: - NCollection_Array1 - updated functionality - NCollection_Array2 - NCollection_Array1 as a wrapper for 2array - NCollection_Vector -> NCollection_DynamicArray was renamed and reworked. TCollection: - Use static empty string to avoid allocations on empty string NCollection allocators update: - NCollection_Allocator - allocator that used Standard::Allocate - NCollection_OccAllocator - allocator-wrapper that used OCC BaseAllocator objects - NCollection_IncAllocator - rework to increase performance Standard: - Rework functionality to use different allocation libs - Implement basic of new way to wrap allocations tools - Define 4 ways to allocation (defines in configure stage) Additional changes: - Hash function uses std::hash functionality - size_t as a hash value - New HashUtils with Murmur and FVN hash algo for x32 and x64 - Deprecated _0.cxx and .gxx DE classes reorganized - Create own utility for std memory - Update Standard_Transient to be more platform-independent Math TK changes: - math_Vector -> match_BaseVector<> - Buffer decreased to cash 32 elements instead of 512
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
#include <QANCollection.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
|
||||
#include <NCollection_StdAllocator.hxx>
|
||||
#include <NCollection_OccAllocator.hxx>
|
||||
#include <NCollection_IncAllocator.hxx>
|
||||
#include <Standard_Assert.hxx>
|
||||
|
||||
@@ -36,7 +36,7 @@ static Standard_Integer QANColStdAllocator1(Draw_Interpretor& di, Standard_Integ
|
||||
|
||||
//type definitions
|
||||
typedef Handle(Standard_Transient) elem_type;
|
||||
typedef NCollection_StdAllocator<elem_type> allocator_type;
|
||||
typedef NCollection_OccAllocator<elem_type> allocator_type;
|
||||
Standard_STATIC_ASSERT (sizeof (allocator_type::value_type) == sizeof (elem_type));
|
||||
Standard_STATIC_ASSERT (sizeof (allocator_type::pointer) == sizeof (void*));
|
||||
Standard_STATIC_ASSERT (sizeof (allocator_type::const_pointer) == sizeof (void*));
|
||||
@@ -71,8 +71,8 @@ static Standard_Integer QANColStdAllocator2(Draw_Interpretor& di, Standard_Integ
|
||||
|
||||
{
|
||||
//typed allocator
|
||||
NCollection_StdAllocator<int> aSAlloc (anIncAlloc);
|
||||
std::list<int, NCollection_StdAllocator<int> > aL (aSAlloc);
|
||||
NCollection_OccAllocator<int> aSAlloc (anIncAlloc);
|
||||
std::list<int, NCollection_OccAllocator<int> > aL (aSAlloc);
|
||||
aL.push_back (2);
|
||||
if ( aL.size() == size_t (1) ) {
|
||||
di << "Test1 : OK\n";
|
||||
@@ -81,8 +81,8 @@ static Standard_Integer QANColStdAllocator2(Draw_Interpretor& di, Standard_Integ
|
||||
}
|
||||
|
||||
//type cast
|
||||
NCollection_StdAllocator<char> aCAlloc;
|
||||
std::vector<int, NCollection_StdAllocator<int> > aV (aCAlloc);
|
||||
NCollection_OccAllocator<char> aCAlloc;
|
||||
std::vector<int, NCollection_OccAllocator<int> > aV (aCAlloc);
|
||||
aV.push_back (1);
|
||||
if ( aV.size() == size_t (1) ) {
|
||||
di << "Test2 : OK\n";
|
||||
@@ -91,8 +91,8 @@ static Standard_Integer QANColStdAllocator2(Draw_Interpretor& di, Standard_Integ
|
||||
}
|
||||
|
||||
//using void-specialization allocator
|
||||
NCollection_StdAllocator<void> aVAlloc;
|
||||
std::vector<int, NCollection_StdAllocator<int> > aV2 (aVAlloc);
|
||||
NCollection_OccAllocator<void*> aVAlloc;
|
||||
std::vector<int, NCollection_OccAllocator<int> > aV2 (aVAlloc);
|
||||
|
||||
aV2.resize (10);
|
||||
aV2.push_back (-1);
|
||||
@@ -108,7 +108,7 @@ static Standard_Integer QANColStdAllocator2(Draw_Interpretor& di, Standard_Integ
|
||||
} else {
|
||||
di << "Test4 : Error\n";
|
||||
}
|
||||
NCollection_StdAllocator<int> anIAlloc (anIncAlloc);
|
||||
NCollection_OccAllocator<int> anIAlloc (anIncAlloc);
|
||||
if ( aSAlloc == anIAlloc ) {
|
||||
di << "Test5 : OK\n";
|
||||
} else {
|
||||
|
@@ -17,11 +17,10 @@
|
||||
#define QANCollection_DataMapOfRealPnt_HeaderFile
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TColStd_MapRealHasher.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
typedef NCollection_DataMap<Standard_Real,gp_Pnt,TColStd_MapRealHasher> QANCollection_DataMapOfRealPnt;
|
||||
typedef NCollection_DataMap<Standard_Real,gp_Pnt,TColStd_MapRealHasher>::Iterator QANCollection_DataMapIteratorOfDataMapOfRealPnt;
|
||||
typedef NCollection_DataMap<Standard_Real,gp_Pnt> QANCollection_DataMapOfRealPnt;
|
||||
typedef NCollection_DataMap<Standard_Real,gp_Pnt>::Iterator QANCollection_DataMapIteratorOfDataMapOfRealPnt;
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -17,12 +17,10 @@
|
||||
#define QANCollection_DoubleMapOfRealInteger_HeaderFile
|
||||
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColStd_MapRealHasher.hxx>
|
||||
#include <TColStd_MapIntegerHasher.hxx>
|
||||
#include <NCollection_DoubleMap.hxx>
|
||||
|
||||
typedef NCollection_DoubleMap<Standard_Real,Standard_Integer,TColStd_MapRealHasher,TColStd_MapIntegerHasher> QANCollection_DoubleMapOfRealInteger;
|
||||
typedef NCollection_DoubleMap<Standard_Real,Standard_Integer,TColStd_MapRealHasher,TColStd_MapIntegerHasher>::Iterator QANCollection_DoubleMapIteratorOfDoubleMapOfRealInteger;
|
||||
typedef NCollection_DoubleMap<Standard_Real,Standard_Integer> QANCollection_DoubleMapOfRealInteger;
|
||||
typedef NCollection_DoubleMap<Standard_Real,Standard_Integer>::Iterator QANCollection_DoubleMapIteratorOfDoubleMapOfRealInteger;
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -16,7 +16,7 @@
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
|
||||
#include <NCollection_StdAllocator.hxx>
|
||||
#include <NCollection_OccAllocator.hxx>
|
||||
#include <NCollection_IncAllocator.hxx>
|
||||
#include <NCollection_HeapAllocator.hxx>
|
||||
#include <OSD_Timer.hxx>
|
||||
|
@@ -17,10 +17,9 @@
|
||||
#define QANCollection_IndexedDataMapOfRealPnt_HeaderFile
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TColStd_MapRealHasher.hxx>
|
||||
#include <NCollection_IndexedDataMap.hxx>
|
||||
|
||||
typedef NCollection_IndexedDataMap<Standard_Real,gp_Pnt,TColStd_MapRealHasher> QANCollection_IndexedDataMapOfRealPnt;
|
||||
typedef NCollection_IndexedDataMap<Standard_Real,gp_Pnt> QANCollection_IndexedDataMapOfRealPnt;
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -46,38 +46,50 @@
|
||||
// So must be defined ::HashCode and ::IsEqual too
|
||||
|
||||
#include <NCollection_DefineHArray1.hxx>
|
||||
#define DEFINE_ARRAY1(_ClassName_, _BaseCollection_, TheItemType) \
|
||||
typedef NCollection_Array1<TheItemType > _ClassName_;
|
||||
|
||||
////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType)
|
||||
////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1)
|
||||
DEFINE_ARRAY1(QANCollection_Array1Perf,QANCollection_BaseColPerf,ItemType)
|
||||
DEFINE_HARRAY1(QANCollection_HArray1Perf,QANCollection_Array1Perf)
|
||||
|
||||
#include <NCollection_DefineHArray2.hxx>
|
||||
#define DEFINE_ARRAY2(_ClassName_, _BaseCollection_, TheItemType) \
|
||||
typedef NCollection_Array2<TheItemType > _ClassName_;
|
||||
////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType)
|
||||
////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2)
|
||||
DEFINE_ARRAY2(QANCollection_Array2Perf,QANCollection_BaseColPerf,ItemType)
|
||||
DEFINE_HARRAY2(QANCollection_HArray2Perf,QANCollection_Array2Perf)
|
||||
|
||||
#include <NCollection_DefineMap.hxx>
|
||||
#include <NCollection_DefineDataMap.hxx>
|
||||
#include <NCollection_DefineDoubleMap.hxx>
|
||||
#include <NCollection_DefineIndexedMap.hxx>
|
||||
#include <NCollection_DefineIndexedDataMap.hxx>
|
||||
////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type)
|
||||
////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType)
|
||||
////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type)
|
||||
////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type)
|
||||
////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType)
|
||||
#define DEFINE_DATAMAP(_ClassName_, _BaseCollection_, TheKeyType, TheItemType) \
|
||||
typedef NCollection_DataMap<TheKeyType, TheItemType > _ClassName_;
|
||||
#define DEFINE_DOUBLEMAP(_ClassName_, _BaseCollection_, TheKey1Type, TheKey2Type) \
|
||||
typedef NCollection_DoubleMap <TheKey1Type, TheKey2Type > _ClassName_;
|
||||
#define DEFINE_INDEXEDDATAMAP(_ClassName_, _BaseCollection_, TheKeyType, TheItemType) \
|
||||
typedef NCollection_IndexedDataMap <TheKeyType, TheItemType > _ClassName_;
|
||||
#define DEFINE_INDEXEDMAP(_ClassName_, _BaseCollection_, TheKeyType) \
|
||||
typedef NCollection_IndexedMap <TheKeyType > _ClassName_;
|
||||
#define DEFINE_MAP(_ClassName_, _BaseCollection_, TheKeyType) \
|
||||
typedef NCollection_Map <TheKeyType > _ClassName_;
|
||||
DEFINE_MAP(QANCollection_MapPerf,QANCollection_Key1BaseColPerf,Key1Type)
|
||||
DEFINE_DATAMAP(QANCollection_DataMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType)
|
||||
DEFINE_DOUBLEMAP(QANCollection_DoubleMapPerf,QANCollection_Key2BaseColPerf,Key1Type,Key2Type)
|
||||
DEFINE_INDEXEDMAP(QANCollection_IndexedMapPerf,QANCollection_Key1BaseColPerf,Key1Type)
|
||||
DEFINE_INDEXEDDATAMAP(QANCollection_IDMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType)
|
||||
|
||||
#include <NCollection_DefineList.hxx>
|
||||
////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType)
|
||||
#define DEFINE_LIST(_ClassName_, _BaseCollection_, TheItemType) \
|
||||
typedef NCollection_List <TheItemType > _ClassName_;
|
||||
DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType)
|
||||
|
||||
#include <NCollection_DefineHSequence.hxx>
|
||||
#define DEFINE_SEQUENCE(_ClassName_, _BaseCollection_, TheItemType) \
|
||||
typedef NCollection_Sequence<TheItemType > _ClassName_;
|
||||
////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType)
|
||||
////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence)
|
||||
DEFINE_SEQUENCE(QANCollection_SequencePerf,QANCollection_BaseColPerf,ItemType)
|
||||
|
@@ -27,65 +27,68 @@
|
||||
|
||||
#include <NCollection_Vector.hxx>
|
||||
#include <NCollection_IncAllocator.hxx>
|
||||
#include <NCollection_Array2.hxx>
|
||||
|
||||
#define ItemType gp_Pnt
|
||||
#define Key1Type Standard_Real
|
||||
#define Key2Type Standard_Integer
|
||||
|
||||
#include <NCollection_DefineHArray1.hxx>
|
||||
#define DEFINE_ARRAY1(_ClassName_, _BaseCollection_, TheItemType) \
|
||||
typedef NCollection_Array1<TheItemType > _ClassName_;
|
||||
////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType)
|
||||
////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1)
|
||||
DEFINE_ARRAY1(QANCollection_Array1Func,QANCollection_BaseColFunc,ItemType)
|
||||
DEFINE_HARRAY1(QANCollection_HArray1Func,QANCollection_Array1Func)
|
||||
|
||||
#include <NCollection_DefineHArray2.hxx>
|
||||
#define DEFINE_ARRAY2(_ClassName_, _BaseCollection_, TheItemType) \
|
||||
typedef NCollection_Array2<TheItemType > _ClassName_;
|
||||
////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType)
|
||||
////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2)
|
||||
DEFINE_ARRAY2(QANCollection_Array2Func,QANCollection_BaseColFunc,ItemType)
|
||||
DEFINE_HARRAY2(QANCollection_HArray2Func,QANCollection_Array2Func)
|
||||
|
||||
#include <NCollection_DefineMap.hxx>
|
||||
#include <NCollection_DefineDataMap.hxx>
|
||||
#include <NCollection_DefineDoubleMap.hxx>
|
||||
#include <NCollection_DefineIndexedMap.hxx>
|
||||
#include <NCollection_DefineIndexedDataMap.hxx>
|
||||
|
||||
////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type)
|
||||
////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType)
|
||||
////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type)
|
||||
////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type)
|
||||
////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType)
|
||||
#include <NCollection_DoubleMap.hxx>
|
||||
#include <NCollection_IndexedMap.hxx>
|
||||
#include <NCollection_IndexedDataMap.hxx>
|
||||
#define DEFINE_DATAMAP(_ClassName_, _BaseCollection_, TheKeyType, TheItemType) \
|
||||
typedef NCollection_DataMap<TheKeyType, TheItemType > _ClassName_;
|
||||
#define DEFINE_DOUBLEMAP(_ClassName_, _BaseCollection_, TheKey1Type, TheKey2Type) \
|
||||
typedef NCollection_DoubleMap <TheKey1Type, TheKey2Type > _ClassName_;
|
||||
#define DEFINE_INDEXEDDATAMAP(_ClassName_, _BaseCollection_, TheKeyType, TheItemType) \
|
||||
typedef NCollection_IndexedDataMap <TheKeyType, TheItemType > _ClassName_;
|
||||
#define DEFINE_INDEXEDMAP(_ClassName_, _BaseCollection_, TheKeyType) \
|
||||
typedef NCollection_IndexedMap <TheKeyType > _ClassName_;
|
||||
#define DEFINE_MAP(_ClassName_, _BaseCollection_, TheKeyType) \
|
||||
typedef NCollection_Map <TheKeyType > _ClassName_;
|
||||
DEFINE_MAP(QANCollection_MapFunc,QANCollection_Key1BaseColFunc,Key1Type)
|
||||
DEFINE_DATAMAP(QANCollection_DataMapFunc,QANCollection_BaseColFunc,Key1Type,ItemType)
|
||||
DEFINE_DOUBLEMAP(QANCollection_DoubleMapFunc,QANCollection_Key2BaseColFunc,Key1Type,Key2Type)
|
||||
DEFINE_INDEXEDMAP(QANCollection_IndexedMapFunc,QANCollection_Key1BaseColFunc,Key1Type)
|
||||
DEFINE_INDEXEDDATAMAP(QANCollection_IDMapFunc,QANCollection_BaseColFunc,Key1Type,ItemType)
|
||||
|
||||
#include <NCollection_DefineList.hxx>
|
||||
////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType)
|
||||
#define DEFINE_LIST(_ClassName_, _BaseCollection_, TheItemType) \
|
||||
typedef NCollection_List <TheItemType > _ClassName_;
|
||||
DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType)
|
||||
DEFINE_LIST(QANCollection_ListFunc,QANCollection_BaseColFunc,ItemType)
|
||||
|
||||
#include <NCollection_DefineHSequence.hxx>
|
||||
#include <NCollection_Sequence.hxx>
|
||||
#define DEFINE_SEQUENCE(_ClassName_, _BaseCollection_, TheItemType) \
|
||||
typedef NCollection_Sequence<TheItemType > _ClassName_;
|
||||
////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType)
|
||||
////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence)
|
||||
DEFINE_SEQUENCE(QANCollection_SequenceFunc,QANCollection_BaseColFunc,ItemType)
|
||||
DEFINE_HSEQUENCE(QANCollection_HSequenceFunc,QANCollection_SequenceFunc)
|
||||
|
||||
// HashCode and IsEquel must be defined for key types of maps
|
||||
|
||||
//! Computes a hash code for the point, in the range [1, theUpperBound]
|
||||
//! @param thePoint the point which hash code is to be computed
|
||||
//! @param theUpperBound the upper bound of the range a computing hash code must be within
|
||||
//! @return a computed hash code, in the range [1, theUpperBound]
|
||||
Standard_Integer HashCode (const gp_Pnt& thePoint, int theUpperBound)
|
||||
{
|
||||
return HashCode (thePoint.X(), theUpperBound);
|
||||
}
|
||||
|
||||
Standard_Boolean IsEqual(const gp_Pnt& theP1, const gp_Pnt& theP2)
|
||||
{
|
||||
return theP1.IsEqual(theP2,gp::Resolution());
|
||||
}
|
||||
|
||||
////////////////////////////////void printCollection (QANCollection_Key1BaseCol& aColl,
|
||||
template <class Coll>
|
||||
void printCollection (Coll& aColl, const char * str)
|
||||
|
Reference in New Issue
Block a user