1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +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:
dpasukhi
2023-08-05 17:53:19 +01:00
parent 6dbfade692
commit 1103eb60af
649 changed files with 10704 additions and 12037 deletions

View File

@@ -63,7 +63,6 @@ TColStd_ListOfAsciiString.hxx
TColStd_ListOfInteger.hxx
TColStd_ListOfReal.hxx
TColStd_ListOfTransient.hxx
TColStd_MapIntegerHasher.hxx
TColStd_MapIteratorOfMapOfAsciiString.hxx
TColStd_MapIteratorOfMapOfInteger.hxx
TColStd_MapIteratorOfMapOfReal.hxx
@@ -73,8 +72,6 @@ TColStd_MapOfAsciiString.hxx
TColStd_MapOfInteger.hxx
TColStd_MapOfReal.hxx
TColStd_MapOfTransient.hxx
TColStd_MapRealHasher.hxx
TColStd_MapTransientHasher.hxx
TColStd_PackedMapOfInteger.cxx
TColStd_PackedMapOfInteger.hxx
TColStd_SequenceOfAddress.hxx

View File

@@ -19,8 +19,8 @@
#include <Standard_Integer.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<TCollection_AsciiString,Standard_Integer,TCollection_AsciiString> TColStd_DataMapOfAsciiStringInteger;
typedef NCollection_DataMap<TCollection_AsciiString,Standard_Integer,TCollection_AsciiString>::Iterator TColStd_DataMapIteratorOfDataMapOfAsciiStringInteger;
typedef NCollection_DataMap<TCollection_AsciiString,Standard_Integer> TColStd_DataMapOfAsciiStringInteger;
typedef NCollection_DataMap<TCollection_AsciiString,Standard_Integer>::Iterator TColStd_DataMapIteratorOfDataMapOfAsciiStringInteger;
#endif

View File

@@ -16,11 +16,10 @@
#define TColStd_DataMapOfIntegerInteger_HeaderFile
#include <Standard_Integer.hxx>
#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<Standard_Integer,Standard_Integer,TColStd_MapIntegerHasher> TColStd_DataMapOfIntegerInteger;
typedef NCollection_DataMap<Standard_Integer,Standard_Integer,TColStd_MapIntegerHasher>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerInteger;
typedef NCollection_DataMap<Standard_Integer,Standard_Integer> TColStd_DataMapOfIntegerInteger;
typedef NCollection_DataMap<Standard_Integer,Standard_Integer>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerInteger;
#endif

View File

@@ -17,11 +17,10 @@
#include <Standard_Integer.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<Standard_Integer,TColStd_ListOfInteger,TColStd_MapIntegerHasher> TColStd_DataMapOfIntegerListOfInteger;
typedef NCollection_DataMap<Standard_Integer,TColStd_ListOfInteger,TColStd_MapIntegerHasher>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger;
typedef NCollection_DataMap<Standard_Integer,TColStd_ListOfInteger> TColStd_DataMapOfIntegerListOfInteger;
typedef NCollection_DataMap<Standard_Integer,TColStd_ListOfInteger>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger;
#endif

View File

@@ -16,11 +16,10 @@
#define TColStd_DataMapOfIntegerReal_HeaderFile
#include <Standard_Integer.hxx>
#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<Standard_Integer,Standard_Real,TColStd_MapIntegerHasher> TColStd_DataMapOfIntegerReal;
typedef NCollection_DataMap<Standard_Integer,Standard_Real,TColStd_MapIntegerHasher>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerReal;
typedef NCollection_DataMap<Standard_Integer,Standard_Real> TColStd_DataMapOfIntegerReal;
typedef NCollection_DataMap<Standard_Integer,Standard_Real>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerReal;
#endif

View File

@@ -17,11 +17,10 @@
#include <Standard_Integer.hxx>
#include <Standard_Transient.hxx>
#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<Standard_Integer,Handle(Standard_Transient),TColStd_MapIntegerHasher> TColStd_DataMapOfIntegerTransient;
typedef NCollection_DataMap<Standard_Integer,Handle(Standard_Transient),TColStd_MapIntegerHasher>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerTransient;
typedef NCollection_DataMap<Standard_Integer,Handle(Standard_Transient)> TColStd_DataMapOfIntegerTransient;
typedef NCollection_DataMap<Standard_Integer,Handle(Standard_Transient)>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerTransient;
#endif

View File

@@ -18,8 +18,8 @@
#include <TCollection_ExtendedString.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Integer,TCollection_ExtendedString> TColStd_DataMapOfStringInteger;
typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Integer,TCollection_ExtendedString>::Iterator TColStd_DataMapIteratorOfDataMapOfStringInteger;
typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Integer> TColStd_DataMapOfStringInteger;
typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Integer>::Iterator TColStd_DataMapIteratorOfDataMapOfStringInteger;
#endif

View File

@@ -16,11 +16,10 @@
#define TColStd_DataMapOfTransientTransient_HeaderFile
#include <Standard_Transient.hxx>
#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<Handle(Standard_Transient),Handle(Standard_Transient),TColStd_MapTransientHasher> TColStd_DataMapOfTransientTransient;
typedef NCollection_DataMap<Handle(Standard_Transient),Handle(Standard_Transient),TColStd_MapTransientHasher>::Iterator TColStd_DataMapIteratorOfDataMapOfTransientTransient;
typedef NCollection_DataMap<Handle(Standard_Transient),Handle(Standard_Transient)> TColStd_DataMapOfTransientTransient;
typedef NCollection_DataMap<Handle(Standard_Transient),Handle(Standard_Transient)>::Iterator TColStd_DataMapIteratorOfDataMapOfTransientTransient;
#endif

View File

@@ -17,6 +17,6 @@
#include <TCollection_AsciiString.hxx>
#include <NCollection_IndexedDataMap.hxx>
typedef NCollection_IndexedDataMap<TCollection_AsciiString,TCollection_AsciiString,TCollection_AsciiString> TColStd_IndexedDataMapOfStringString;
typedef NCollection_IndexedDataMap<TCollection_AsciiString,TCollection_AsciiString> TColStd_IndexedDataMapOfStringString;
#endif // TColStd_IndexedDataMapOfStringString_HeaderFile

View File

@@ -16,10 +16,9 @@
#define TColStd_IndexedDataMapOfTransientTransient_HeaderFile
#include <Standard_Transient.hxx>
#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_IndexedDataMap.hxx>
typedef NCollection_IndexedDataMap<Handle(Standard_Transient),Handle(Standard_Transient),TColStd_MapTransientHasher> TColStd_IndexedDataMapOfTransientTransient;
typedef NCollection_IndexedDataMap<Handle(Standard_Transient),Handle(Standard_Transient)> TColStd_IndexedDataMapOfTransientTransient;
#endif

View File

@@ -16,10 +16,9 @@
#define TColStd_IndexedMapOfInteger_HeaderFile
#include <Standard_Integer.hxx>
#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_IndexedMap.hxx>
typedef NCollection_IndexedMap<Standard_Integer,TColStd_MapIntegerHasher> TColStd_IndexedMapOfInteger;
typedef NCollection_IndexedMap<Standard_Integer> TColStd_IndexedMapOfInteger;
#endif

View File

@@ -15,10 +15,9 @@
#ifndef TColStd_IndexedMapOfReal_HeaderFile
#define TColStd_IndexedMapOfReal_HeaderFile
#include <TColStd_MapRealHasher.hxx>
#include <NCollection_IndexedMap.hxx>
typedef NCollection_IndexedMap<Standard_Real,TColStd_MapRealHasher> TColStd_IndexedMapOfReal;
typedef NCollection_IndexedMap<Standard_Real> TColStd_IndexedMapOfReal;
#endif

View File

@@ -16,10 +16,9 @@
#define TColStd_IndexedMapOfTransient_HeaderFile
#include <Standard_Transient.hxx>
#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_IndexedMap.hxx>
typedef NCollection_IndexedMap<Handle(Standard_Transient),TColStd_MapTransientHasher> TColStd_IndexedMapOfTransient;
typedef NCollection_IndexedMap<Handle(Standard_Transient)> TColStd_IndexedMapOfTransient;
#endif

View File

@@ -1,24 +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.
#ifndef TColStd_MapIntegerHasher_HeaderFile
#define TColStd_MapIntegerHasher_HeaderFile
#include <Standard_Integer.hxx>
#include <NCollection_DefaultHasher.hxx>
typedef NCollection_DefaultHasher<Standard_Integer> TColStd_MapIntegerHasher;
#endif

View File

@@ -18,8 +18,8 @@
#include <TCollection_AsciiString.hxx>
#include <NCollection_Map.hxx>
typedef NCollection_Map<TCollection_AsciiString,TCollection_AsciiString> TColStd_MapOfAsciiString;
typedef NCollection_Map<TCollection_AsciiString,TCollection_AsciiString>::Iterator TColStd_MapIteratorOfMapOfAsciiString;
typedef NCollection_Map<TCollection_AsciiString> TColStd_MapOfAsciiString;
typedef NCollection_Map<TCollection_AsciiString>::Iterator TColStd_MapIteratorOfMapOfAsciiString;
#endif

View File

@@ -16,11 +16,10 @@
#define TColStd_MapOfInteger_HeaderFile
#include <Standard_Integer.hxx>
#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_Map.hxx>
typedef NCollection_Map<Standard_Integer,TColStd_MapIntegerHasher> TColStd_MapOfInteger;
typedef NCollection_Map<Standard_Integer,TColStd_MapIntegerHasher>::Iterator TColStd_MapIteratorOfMapOfInteger;
typedef NCollection_Map<Standard_Integer> TColStd_MapOfInteger;
typedef NCollection_Map<Standard_Integer>::Iterator TColStd_MapIteratorOfMapOfInteger;
#endif

View File

@@ -15,11 +15,10 @@
#ifndef TColStd_MapOfReal_HeaderFile
#define TColStd_MapOfReal_HeaderFile
#include <TColStd_MapRealHasher.hxx>
#include <NCollection_Map.hxx>
typedef NCollection_Map<Standard_Real,TColStd_MapRealHasher> TColStd_MapOfReal;
typedef NCollection_Map<Standard_Real,TColStd_MapRealHasher>::Iterator TColStd_MapIteratorOfMapOfReal;
typedef NCollection_Map<Standard_Real> TColStd_MapOfReal;
typedef NCollection_Map<Standard_Real>::Iterator TColStd_MapIteratorOfMapOfReal;
#endif

View File

@@ -16,11 +16,10 @@
#define TColStd_MapOfTransient_HeaderFile
#include <Standard_Transient.hxx>
#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_Map.hxx>
typedef NCollection_Map<Handle(Standard_Transient),TColStd_MapTransientHasher> TColStd_MapOfTransient;
typedef NCollection_Map<Handle(Standard_Transient),TColStd_MapTransientHasher>::Iterator TColStd_MapIteratorOfMapOfTransient;
typedef NCollection_Map<Handle(Standard_Transient)> TColStd_MapOfTransient;
typedef NCollection_Map<Handle(Standard_Transient)>::Iterator TColStd_MapIteratorOfMapOfTransient;
#endif

View File

@@ -1,23 +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.
#ifndef TColStd_MapRealHasher_HeaderFile
#define TColStd_MapRealHasher_HeaderFile
#include <NCollection_DefaultHasher.hxx>
typedef NCollection_DefaultHasher<Standard_Real> TColStd_MapRealHasher;
#endif

View File

@@ -1,24 +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.
#ifndef TColStd_MapTransientHasher_HeaderFile
#define TColStd_MapTransientHasher_HeaderFile
#include <Standard_Transient.hxx>
#include <NCollection_DefaultHasher.hxx>
typedef NCollection_DefaultHasher<Handle(Standard_Transient)> TColStd_MapTransientHasher;
#endif

View File

@@ -18,6 +18,15 @@
#include <NCollection_Array1.hxx>
#include <TCollection.hxx>
namespace
{
size_t HashCode(const int theKey,
const size_t theBound)
{
return static_cast<size_t>(theKey) % theBound + 1;
}
}
//=======================================================================
//function : TColStd_intMapNode_findNext
//purpose :
@@ -122,7 +131,7 @@ TColStd_PackedMapOfInteger& TColStd_PackedMapOfInteger::Assign
{
for (const TColStd_intMapNode* p = theOther.myData1[i]; p != NULL; )
{
const Standard_Integer aHashCode = p->HashCode(nBuckets);
const size_t aHashCode = p->HashCode(nBuckets);
myData1[aHashCode] = new TColStd_intMapNode (p->Mask(), p->Data(), myData1[aHashCode]);
++myNbPackedMapNodes;
p = p->Next();
@@ -154,7 +163,7 @@ void TColStd_PackedMapOfInteger::ReSize (const Standard_Integer theNbBuckets)
aNewBuck = myNbBuckets;
}
TColStd_intMapNode** aNewData = (TColStd_intMapNode** )Standard::Allocate ((aNewBuck + 1) * sizeof(TColStd_intMapNode*));
TColStd_intMapNode** aNewData = (TColStd_intMapNode** )Standard::AllocateOptimal ((aNewBuck + 1) * sizeof(TColStd_intMapNode*));
memset (aNewData, 0, (aNewBuck + 1) * sizeof(TColStd_intMapNode*));
if (myData1 != NULL)
{
@@ -163,7 +172,7 @@ void TColStd_PackedMapOfInteger::ReSize (const Standard_Integer theNbBuckets)
{
for (TColStd_intMapNode* p = anOldData[i]; p != NULL; )
{
Standard_Integer k = p->HashCode (aNewBuck);
size_t k = p->HashCode(aNewBuck);
TColStd_intMapNode* q = p->Next();
p->SetNext (aNewData[k]);
aNewData[k] = p;
@@ -219,7 +228,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Add (const Standard_Integer aKey)
}
const Standard_Integer aKeyInt = packedKeyIndex (aKey);
const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
TColStd_intMapNode* aBucketHead = myData1[aHashCode];
for (TColStd_intMapNode* p = aBucketHead; p != NULL; p = p->Next())
{
@@ -426,7 +435,7 @@ void TColStd_PackedMapOfInteger::Union (const TColStd_PackedMapOfInteger& theMap
if (Resizable()) {
ReSize (myNbPackedMapNodes);
}
const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode] = new TColStd_intMapNode (aNewMask, aNewData,
myData1[aHashCode]);
++myNbPackedMapNodes;
@@ -459,7 +468,7 @@ void TColStd_PackedMapOfInteger::Union (const TColStd_PackedMapOfInteger& theMap
{
ReSize (myNbPackedMapNodes);
}
const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode]= new TColStd_intMapNode (p2->Mask(), p2->Data(),
myData1[aHashCode]);
++myNbPackedMapNodes;
@@ -498,7 +507,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Unite(const TColStd_PackedMapOfInte
const Standard_Integer aKey = p2->Key();
const Standard_Integer aKeyInt = packedKeyIndex (aKey);
// Find the corresponding block in the 1st (this) map
Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
TColStd_intMapNode* p1 = myData1[aHashCode];
while (p1)
{
@@ -594,7 +603,7 @@ void TColStd_PackedMapOfInteger::Intersection
{
ReSize (myNbPackedMapNodes);
}
const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
unsigned int aNewMask = p1->Mask();
myExtent += TColStd_Population (aNewMask, aNewData);
myData1[aHashCode]= new TColStd_intMapNode(aNewMask, aNewData,
@@ -739,7 +748,7 @@ void TColStd_PackedMapOfInteger::Subtraction
{
ReSize (myNbPackedMapNodes);
}
const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode]= new TColStd_intMapNode (aNewMask, aNewData,
myData1[aHashCode]);
++myNbPackedMapNodes;
@@ -877,7 +886,7 @@ void TColStd_PackedMapOfInteger::Difference (const TColStd_PackedMapOfInteger&
{
ReSize (myNbPackedMapNodes);
}
const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode]= new TColStd_intMapNode (aNewMask, aNewData,
myData1[aHashCode]);
++myNbPackedMapNodes;
@@ -912,7 +921,7 @@ void TColStd_PackedMapOfInteger::Difference (const TColStd_PackedMapOfInteger&
{
ReSize (myNbPackedMapNodes);
}
const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode]= new TColStd_intMapNode (p2->Mask(), p2->Data(),
myData1[aHashCode]);
++myNbPackedMapNodes;
@@ -992,7 +1001,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Differ(const TColStd_PackedMapOfInt
{
ReSize (myNbPackedMapNodes);
}
const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode] = new TColStd_intMapNode (p2->Mask(), p2->Data(),
myData1[aHashCode]);
++myNbPackedMapNodes;

View File

@@ -17,7 +17,6 @@
#define TColStd_PackedMapOfInteger_HeaderFile
#include <Standard.hxx>
#include <Standard_Address.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Integer.hxx>
@@ -125,7 +124,7 @@ private:
//! Support of Map interface.
Standard_Integer HashCode (Standard_Integer theUpper) const
{
return ::HashCode (Standard_Integer(myMask >> 5), theUpper);
return (myMask >> 5) % theUpper + 1;
}
//! Support of Map interface.

View File

@@ -15,7 +15,6 @@
#ifndef TColStd_SequenceOfAddress_HeaderFile
#define TColStd_SequenceOfAddress_HeaderFile
#include <Standard_Address.hxx>
#include <NCollection_Sequence.hxx>
typedef NCollection_Sequence<Standard_Address> TColStd_SequenceOfAddress;