mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-07 18:30:55 +03:00
0024911: Avoid using virtual functions in NCollection classes
NCollection_BaseCollection class, relevant header files, and macro DEFINE_BASECOLLECTION removed. Hence methods Assign() from other compatible (via inheritance of BaseCollection) collections are not available any more, as well as base Iterator class. All methods of Iterator classes are made non-virtual, allowing their inline expansion for better performance. OCCT-specific operators new and delete added to collection classes and removed from iterator classes.
This commit is contained in:
parent
598fcce93c
commit
ddf2fe8eeb
src
AIS
BOPAlgo
BOPCol
BOPDS
Font
GeomInt
Graphic3d
Message
NCollection
FILESNCollection_Array1.hxxNCollection_Array2.hxxNCollection_BaseAllocator.cxxNCollection_BaseCollection.hxxNCollection_BaseList.cxxNCollection_BaseList.hxxNCollection_BaseMap.cxxNCollection_BaseMap.hxxNCollection_BaseSequence.cxxNCollection_BaseSequence.hxxNCollection_BaseVector.cxxNCollection_BaseVector.hxxNCollection_Buffer.hxxNCollection_CellFilter.hxxNCollection_DataMap.hxxNCollection_DefineArray1.hxxNCollection_DefineArray2.hxxNCollection_DefineBaseCollection.hxxNCollection_DefineDataMap.hxxNCollection_DefineDoubleMap.hxxNCollection_DefineHArray1.hxxNCollection_DefineHArray2.hxxNCollection_DefineHSequence.hxxNCollection_DefineIndexedDataMap.hxxNCollection_DefineIndexedMap.hxxNCollection_DefineMap.hxxNCollection_DefineSequence.hxxNCollection_DefineTListIterator.hxxNCollection_DefineTListNode.hxxNCollection_DefineVector.hxxNCollection_DoubleMap.hxxNCollection_IndexedDataMap.hxxNCollection_IndexedMap.hxxNCollection_List.hxxNCollection_ListNode.hxxNCollection_LocalArray.hxxNCollection_Map.hxxNCollection_Sequence.hxxNCollection_StdBase.hxxNCollection_StlIterator.hxxNCollection_TListIterator.hxxNCollection_TListNode.hxxNCollection_UBTree.hxxNCollection_Vector.hxx
Prs3d
SelectMgr
TObj
TObj_Container.hxxTObj_Model.hxxTObj_SequenceOfIterator.hxxTObj_SequenceOfObject.hxxTObj_TNameContainer.cxx
Visual3d
Voxel
VrmlData
@ -17,13 +17,9 @@
|
|||||||
#define _AIS_NDataMapOfTransientIteratorOfListTransient_HeaderFile
|
#define _AIS_NDataMapOfTransientIteratorOfListTransient_HeaderFile
|
||||||
|
|
||||||
#include <AIS_NListIteratorOfListTransient.hxx>
|
#include <AIS_NListIteratorOfListTransient.hxx>
|
||||||
#include <NCollection_DefineDataMap.hxx>
|
#include <NCollection_DataMap.hxx>
|
||||||
|
|
||||||
DEFINE_BASECOLLECTION(AIS_BaseCollItListTransient,
|
typedef NCollection_DataMap<Handle(Standard_Transient), AIS_NListIteratorOfListTransient>
|
||||||
AIS_NListIteratorOfListTransient)
|
AIS_NDataMapOfTransientIteratorOfListTransient;
|
||||||
DEFINE_DATAMAP (AIS_NDataMapOfTransientIteratorOfListTransient,
|
|
||||||
AIS_BaseCollItListTransient,
|
|
||||||
Handle(Standard_Transient),
|
|
||||||
AIS_NListIteratorOfListTransient)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,11 +17,8 @@
|
|||||||
#define _AIS_NListTransient_HeaderFile
|
#define _AIS_NListTransient_HeaderFile
|
||||||
|
|
||||||
#include <Standard_Transient.hxx>
|
#include <Standard_Transient.hxx>
|
||||||
#include <NCollection_StdBase.hxx>
|
#include <NCollection_List.hxx>
|
||||||
#include <NCollection_DefineList.hxx>
|
|
||||||
|
|
||||||
DEFINE_LIST (AIS_NListTransient,
|
typedef NCollection_List<Handle(Standard_Transient)> AIS_NListTransient;
|
||||||
NCollection_BaseCollTransient,
|
|
||||||
Handle(Standard_Transient))
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include <BOPAlgo_BuilderSolid.hxx>
|
#include <BOPAlgo_BuilderSolid.hxx>
|
||||||
|
|
||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <NCollection_IncAllocator.hxx>
|
||||||
|
|
||||||
static
|
static
|
||||||
TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim);
|
TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim);
|
||||||
|
@ -30,27 +30,23 @@ template <class Type> class BOPCol_NCVector
|
|||||||
public:
|
public:
|
||||||
BOPCol_NCVector(const Standard_Integer theIncrement=256,
|
BOPCol_NCVector(const Standard_Integer theIncrement=256,
|
||||||
const Handle(NCollection_BaseAllocator)& theAlloc = NULL)
|
const Handle(NCollection_BaseAllocator)& theAlloc = NULL)
|
||||||
: NCollection_Vector<Type>(theIncrement, theAlloc) {
|
: NCollection_Vector<Type>(theIncrement, theAlloc)
|
||||||
};
|
{}
|
||||||
//
|
//
|
||||||
BOPCol_NCVector(const BOPCol_NCVector& theOther)
|
BOPCol_NCVector(const BOPCol_NCVector& theOther)
|
||||||
: NCollection_Vector<Type>(theOther) {
|
: NCollection_Vector<Type>(theOther)
|
||||||
};
|
{}
|
||||||
//
|
//
|
||||||
Type& Append1 ()
|
Type& Append1 ()
|
||||||
{
|
{
|
||||||
Type& anAppended =
|
Type& anAppended = *(Type*)this->expandV (this->myLength);
|
||||||
*(Type* )NCollection_BaseVector::expandV (NCollection_BaseCollection<Type>::myAllocator,
|
|
||||||
NCollection_Vector<Type>::myLength);
|
|
||||||
return anAppended;
|
return anAppended;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
Standard_Integer Extent() const
|
Standard_Integer Extent() const
|
||||||
{
|
{
|
||||||
return NCollection_Vector<Type>::myLength;
|
return this->myLength;
|
||||||
}
|
}
|
||||||
protected:
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
//
|
//
|
||||||
#include <Bnd_Box.hxx>
|
#include <Bnd_Box.hxx>
|
||||||
//
|
//
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
#include <NCollection_IncAllocator.hxx>
|
||||||
#include <NCollection_UBTreeFiller.hxx>
|
#include <NCollection_UBTreeFiller.hxx>
|
||||||
//
|
//
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
|
|
||||||
#include <NCollection_UBTreeFiller.hxx>
|
#include <NCollection_UBTreeFiller.hxx>
|
||||||
|
#include <NCollection_IncAllocator.hxx>
|
||||||
|
|
||||||
#include <BOPCol_BoxBndTree.hxx>
|
#include <BOPCol_BoxBndTree.hxx>
|
||||||
#include <BOPDS_IndexRange.hxx>
|
#include <BOPDS_IndexRange.hxx>
|
||||||
#include <BOPDS_PassKeyBoolean.hxx>
|
#include <BOPDS_PassKeyBoolean.hxx>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
//
|
//
|
||||||
#include <Bnd_Box.hxx>
|
#include <Bnd_Box.hxx>
|
||||||
//
|
//
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
#include <NCollection_IncAllocator.hxx>
|
||||||
#include <NCollection_UBTreeFiller.hxx>
|
#include <NCollection_UBTreeFiller.hxx>
|
||||||
//
|
//
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
|
|
||||||
#ifndef _Font_NListOfSystemFont_HeaderFile
|
#ifndef _Font_NListOfSystemFont_HeaderFile
|
||||||
#define _Font_NListOfSystemFont_HeaderFile
|
#define _Font_NListOfSystemFont_HeaderFile
|
||||||
#include <NCollection_DefineList.hxx>
|
|
||||||
|
#include <NCollection_List.hxx>
|
||||||
#include <Font_SystemFont.hxx>
|
#include <Font_SystemFont.hxx>
|
||||||
DEFINE_LIST (Font_NListOfSystemFont,
|
|
||||||
NCollection_List,
|
typedef NCollection_List<Handle(Font_SystemFont)> Font_NListOfSystemFont;
|
||||||
Handle(Font_SystemFont))
|
|
||||||
|
|
||||||
inline Standard_Boolean IsEqual (const Handle(Font_SystemFont)& theFirstFont,
|
inline Standard_Boolean IsEqual (const Handle(Font_SystemFont)& theFirstFont,
|
||||||
const Handle(Font_SystemFont)& theSecondFont)
|
const Handle(Font_SystemFont)& theSecondFont)
|
||||||
|
@ -1507,7 +1507,7 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine,
|
|||||||
aNbListOfPointIndex=aListOfPointIndex.Extent();
|
aNbListOfPointIndex=aListOfPointIndex.Extent();
|
||||||
if(aNbListOfPointIndex) {
|
if(aNbListOfPointIndex) {
|
||||||
nblines++;
|
nblines++;
|
||||||
anArrayOfLines[nblines] = aListOfPointIndex;
|
anArrayOfLines[nblines].Assign (aListOfPointIndex);
|
||||||
anArrayOfLineType[nblines] = bIsPrevPointOnBoundary;
|
anArrayOfLineType[nblines] = bIsPrevPointOnBoundary;
|
||||||
aListOfPointIndex.Clear();
|
aListOfPointIndex.Clear();
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,9 @@
|
|||||||
#ifndef _Graphic3d_NListOfHAsciiString_HeaderFile
|
#ifndef _Graphic3d_NListOfHAsciiString_HeaderFile
|
||||||
#define _Graphic3d_NListOfHAsciiString_HeaderFile
|
#define _Graphic3d_NListOfHAsciiString_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineList.hxx>
|
#include <NCollection_List.hxx>
|
||||||
#include <TCollection_HAsciiString.hxx>
|
#include <TCollection_HAsciiString.hxx>
|
||||||
|
|
||||||
DEFINE_LIST (Graphic3d_NListOfHAsciiString,
|
typedef NCollection_List<Handle(TCollection_HAsciiString)> Graphic3d_NListOfHAsciiString;
|
||||||
NCollection_List,
|
|
||||||
Handle(TCollection_HAsciiString))
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,19 +15,15 @@
|
|||||||
|
|
||||||
#include <Message_MsgFile.hxx>
|
#include <Message_MsgFile.hxx>
|
||||||
|
|
||||||
|
#include <NCollection_DataMap.hxx>
|
||||||
|
#include <OSD_Environment.hxx>
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
#include <TCollection_ExtendedString.hxx>
|
#include <TCollection_ExtendedString.hxx>
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_DefineDataMap.hxx>
|
|
||||||
#include <OSD_Environment.hxx>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
DEFINE_BASECOLLECTION(Message_CollectionOfExtendedString, TCollection_ExtendedString)
|
typedef NCollection_DataMap<TCollection_AsciiString,TCollection_ExtendedString> Message_DataMapOfExtendedString;
|
||||||
DEFINE_DATAMAP(Message_DataMapOfExtendedString,
|
|
||||||
Message_CollectionOfExtendedString,
|
|
||||||
TCollection_AsciiString,
|
|
||||||
TCollection_ExtendedString)
|
|
||||||
|
|
||||||
static Message_DataMapOfExtendedString& msgsDataMap ()
|
static Message_DataMapOfExtendedString& msgsDataMap ()
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,6 @@ NCollection_BaseSequence.cxx
|
|||||||
NCollection_BaseMap.hxx
|
NCollection_BaseMap.hxx
|
||||||
NCollection_BaseMap.cxx
|
NCollection_BaseMap.cxx
|
||||||
|
|
||||||
NCollection_BaseCollection.hxx
|
|
||||||
NCollection_TListNode.hxx
|
NCollection_TListNode.hxx
|
||||||
NCollection_TListIterator.hxx
|
NCollection_TListIterator.hxx
|
||||||
NCollection_Sequence.hxx
|
NCollection_Sequence.hxx
|
||||||
@ -34,9 +33,6 @@ NCollection_DoubleMap.hxx
|
|||||||
NCollection_IndexedMap.hxx
|
NCollection_IndexedMap.hxx
|
||||||
NCollection_IndexedDataMap.hxx
|
NCollection_IndexedDataMap.hxx
|
||||||
|
|
||||||
NCollection_DefineBaseCollection.hxx
|
|
||||||
NCollection_DefineTListIterator.hxx
|
|
||||||
NCollection_DefineTListNode.hxx
|
|
||||||
NCollection_DefineArray1.hxx
|
NCollection_DefineArray1.hxx
|
||||||
NCollection_DefineHArray1.hxx
|
NCollection_DefineHArray1.hxx
|
||||||
NCollection_DefineArray2.hxx
|
NCollection_DefineArray2.hxx
|
||||||
@ -54,7 +50,6 @@ NCollection_BaseVector.hxx
|
|||||||
NCollection_BaseVector.cxx
|
NCollection_BaseVector.cxx
|
||||||
NCollection_Vector.hxx
|
NCollection_Vector.hxx
|
||||||
NCollection_DefineVector.hxx
|
NCollection_DefineVector.hxx
|
||||||
NCollection_StdBase.hxx
|
|
||||||
|
|
||||||
NCollection_EBTree.hxx
|
NCollection_EBTree.hxx
|
||||||
NCollection_UBTree.hxx
|
NCollection_UBTree.hxx
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <Standard_OutOfRange.hxx>
|
#include <Standard_OutOfRange.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <NCollection_BaseCollection.hxx>
|
#include <NCollection_DefineAlloc.hxx>
|
||||||
#include <NCollection_StlIterator.hxx>
|
#include <NCollection_StlIterator.hxx>
|
||||||
|
|
||||||
// *********************************************** Template for Array1 class
|
// *********************************************** Template for Array1 class
|
||||||
@ -55,8 +55,8 @@
|
|||||||
* compatibility the method IsAllocated remained in class along
|
* compatibility the method IsAllocated remained in class along
|
||||||
* with IsDeletable.
|
* with IsDeletable.
|
||||||
*/
|
*/
|
||||||
template <class TheItemType> class NCollection_Array1
|
template <class TheItemType>
|
||||||
: public NCollection_BaseCollection<TheItemType>
|
class NCollection_Array1
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! STL-compliant typedef for value type
|
//! STL-compliant typedef for value type
|
||||||
@ -64,7 +64,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
//! Implementation of the Iterator interface.
|
//! Implementation of the Iterator interface.
|
||||||
class Iterator : public NCollection_BaseCollection<TheItemType>::Iterator
|
class Iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -99,35 +99,35 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Check end
|
//! Check end
|
||||||
virtual Standard_Boolean More (void) const
|
Standard_Boolean More (void) const
|
||||||
{ return myPtrCur < myPtrEnd; }
|
{ return myPtrCur < myPtrEnd; }
|
||||||
|
|
||||||
//! Increment operator
|
//! Increment operator
|
||||||
virtual void Next (void)
|
void Next (void)
|
||||||
{ ++myPtrCur; }
|
{ ++myPtrCur; }
|
||||||
|
|
||||||
//! Decrement operator
|
//! Decrement operator
|
||||||
virtual void Previous()
|
void Previous()
|
||||||
{ --myPtrCur; }
|
{ --myPtrCur; }
|
||||||
|
|
||||||
//! Offset operator.
|
//! Offset operator.
|
||||||
virtual void Offset (ptrdiff_t theOffset)
|
void Offset (ptrdiff_t theOffset)
|
||||||
{ myPtrCur += theOffset; }
|
{ myPtrCur += theOffset; }
|
||||||
|
|
||||||
//! Difference operator.
|
//! Difference operator.
|
||||||
virtual ptrdiff_t Differ (const Iterator& theOther) const
|
ptrdiff_t Differ (const Iterator& theOther) const
|
||||||
{ return myPtrCur - theOther.myPtrCur; }
|
{ return myPtrCur - theOther.myPtrCur; }
|
||||||
|
|
||||||
//! Constant value access
|
//! Constant value access
|
||||||
virtual const TheItemType& Value (void) const
|
const TheItemType& Value (void) const
|
||||||
{ return *myPtrCur; }
|
{ return *myPtrCur; }
|
||||||
|
|
||||||
//! Variable value access
|
//! Variable value access
|
||||||
virtual TheItemType& ChangeValue (void) const
|
TheItemType& ChangeValue (void) const
|
||||||
{ return *myPtrCur; }
|
{ return *myPtrCur; }
|
||||||
|
|
||||||
//! Performs comparison of two iterators
|
//! Performs comparison of two iterators
|
||||||
virtual Standard_Boolean IsEqual (const Iterator& theOther) const
|
Standard_Boolean IsEqual (const Iterator& theOther) const
|
||||||
{ return myPtrCur == theOther.myPtrCur; }
|
{ return myPtrCur == theOther.myPtrCur; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -159,7 +159,6 @@ public:
|
|||||||
//! Constructor
|
//! Constructor
|
||||||
NCollection_Array1(const Standard_Integer theLower,
|
NCollection_Array1(const Standard_Integer theLower,
|
||||||
const Standard_Integer theUpper) :
|
const Standard_Integer theUpper) :
|
||||||
NCollection_BaseCollection<TheItemType> (),
|
|
||||||
myLowerBound (theLower),
|
myLowerBound (theLower),
|
||||||
myUpperBound (theUpper),
|
myUpperBound (theUpper),
|
||||||
myDeletable (Standard_True)
|
myDeletable (Standard_True)
|
||||||
@ -179,7 +178,6 @@ public:
|
|||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
NCollection_Array1 (const NCollection_Array1& theOther) :
|
NCollection_Array1 (const NCollection_Array1& theOther) :
|
||||||
NCollection_BaseCollection<TheItemType> (),
|
|
||||||
myLowerBound (theOther.Lower()),
|
myLowerBound (theOther.Lower()),
|
||||||
myUpperBound (theOther.Upper()),
|
myUpperBound (theOther.Upper()),
|
||||||
myDeletable (Standard_True)
|
myDeletable (Standard_True)
|
||||||
@ -198,7 +196,6 @@ public:
|
|||||||
NCollection_Array1 (const TheItemType& theBegin,
|
NCollection_Array1 (const TheItemType& theBegin,
|
||||||
const Standard_Integer theLower,
|
const Standard_Integer theLower,
|
||||||
const Standard_Integer theUpper) :
|
const Standard_Integer theUpper) :
|
||||||
NCollection_BaseCollection<TheItemType> (),
|
|
||||||
myLowerBound (theLower),
|
myLowerBound (theLower),
|
||||||
myUpperBound (theUpper),
|
myUpperBound (theUpper),
|
||||||
myDeletable (Standard_False)
|
myDeletable (Standard_False)
|
||||||
@ -219,7 +216,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Size query
|
//! Size query
|
||||||
virtual Standard_Integer Size (void) const
|
Standard_Integer Size (void) const
|
||||||
{ return Length(); }
|
{ return Length(); }
|
||||||
//! Length query (the same)
|
//! Length query (the same)
|
||||||
Standard_Integer Length (void) const
|
Standard_Integer Length (void) const
|
||||||
@ -240,27 +237,8 @@ public:
|
|||||||
Standard_Boolean IsAllocated (void) const
|
Standard_Boolean IsAllocated (void) const
|
||||||
{ return myDeletable; }
|
{ return myDeletable; }
|
||||||
|
|
||||||
//! Assign (any collection to this array)
|
//! Assignment
|
||||||
// Copies items from the other collection into the allocated
|
NCollection_Array1& Assign (const NCollection_Array1& theOther)
|
||||||
// storage. Raises an exception when sizes differ.
|
|
||||||
virtual void Assign (const NCollection_BaseCollection<TheItemType>& theOther)
|
|
||||||
{
|
|
||||||
if (&theOther == this)
|
|
||||||
return;
|
|
||||||
#if !defined No_Exception && !defined No_Standard_DimensionMismatch
|
|
||||||
if (Length() != theOther.Size())
|
|
||||||
Standard_DimensionMismatch::Raise ("NCollection_Array1::Assign");
|
|
||||||
#endif
|
|
||||||
TYPENAME NCollection_BaseCollection<TheItemType>::Iterator& anIter2 =
|
|
||||||
theOther.CreateIterator();
|
|
||||||
TheItemType * const pEndItem = &myData[myUpperBound];
|
|
||||||
for (TheItemType * pItem = &myData[myLowerBound];
|
|
||||||
pItem <= pEndItem; anIter2.Next())
|
|
||||||
* pItem ++ = anIter2.Value();
|
|
||||||
}
|
|
||||||
|
|
||||||
//! operator= (array to array)
|
|
||||||
NCollection_Array1& operator= (const NCollection_Array1& theOther)
|
|
||||||
{
|
{
|
||||||
if (&theOther == this)
|
if (&theOther == this)
|
||||||
return *this;
|
return *this;
|
||||||
@ -275,6 +253,12 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Assignment operator
|
||||||
|
NCollection_Array1& operator= (const NCollection_Array1& theOther)
|
||||||
|
{
|
||||||
|
return Assign (theOther);
|
||||||
|
}
|
||||||
|
|
||||||
//! @return first element
|
//! @return first element
|
||||||
const TheItemType& First() const
|
const TheItemType& First() const
|
||||||
{
|
{
|
||||||
@ -342,15 +326,6 @@ public:
|
|||||||
~NCollection_Array1 (void)
|
~NCollection_Array1 (void)
|
||||||
{ if (myDeletable) delete [] &(myData[myLowerBound]); }
|
{ if (myDeletable) delete [] &(myData[myLowerBound]); }
|
||||||
|
|
||||||
private:
|
|
||||||
// ----------- PRIVATE METHODS -----------
|
|
||||||
|
|
||||||
// ******** Creates Iterator for use on BaseCollection
|
|
||||||
virtual
|
|
||||||
TYPENAME NCollection_BaseCollection<TheItemType>::Iterator&
|
|
||||||
CreateIterator(void) const
|
|
||||||
{ return *(new (this->IterAllocator()) Iterator(*this)); }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ---------- PROTECTED FIELDS -----------
|
// ---------- PROTECTED FIELDS -----------
|
||||||
Standard_Integer myLowerBound;
|
Standard_Integer myLowerBound;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <Standard_OutOfRange.hxx>
|
#include <Standard_OutOfRange.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <NCollection_BaseCollection.hxx>
|
#include <NCollection_DefineAlloc.hxx>
|
||||||
|
|
||||||
// *********************************************** Template for Array2 class
|
// *********************************************** Template for Array2 class
|
||||||
/**
|
/**
|
||||||
@ -37,8 +37,8 @@
|
|||||||
* for (i = A.LowerRow(); i <= A.UpperRow(); i++)
|
* for (i = A.LowerRow(); i <= A.UpperRow(); i++)
|
||||||
* for (j = A.LowerCol(); j <= A.UpperCol(); j++)
|
* for (j = A.LowerCol(); j <= A.UpperCol(); j++)
|
||||||
*/
|
*/
|
||||||
template <class TheItemType> class NCollection_Array2
|
template <class TheItemType>
|
||||||
: public NCollection_BaseCollection<TheItemType>
|
class NCollection_Array2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! STL-compliant typedef for value type
|
//! STL-compliant typedef for value type
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// **************** Implementation of the Iterator interface.
|
// **************** Implementation of the Iterator interface.
|
||||||
class Iterator : public NCollection_BaseCollection<TheItemType>::Iterator
|
class Iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Empty constructor - for later Init
|
//! Empty constructor - for later Init
|
||||||
@ -67,16 +67,16 @@ public:
|
|||||||
myArray = (NCollection_Array2 *) &theArray;
|
myArray = (NCollection_Array2 *) &theArray;
|
||||||
}
|
}
|
||||||
//! Check end
|
//! Check end
|
||||||
virtual Standard_Boolean More (void) const
|
Standard_Boolean More (void) const
|
||||||
{ return (myCurrent < mySize); }
|
{ return (myCurrent < mySize); }
|
||||||
//! Make step
|
//! Make step
|
||||||
virtual void Next (void)
|
void Next (void)
|
||||||
{ myCurrent++; }
|
{ myCurrent++; }
|
||||||
//! Constant value access
|
//! Constant value access
|
||||||
virtual const TheItemType& Value (void) const
|
const TheItemType& Value (void) const
|
||||||
{ return myArray->myStart[myCurrent]; }
|
{ return myArray->myStart[myCurrent]; }
|
||||||
//! Variable value access
|
//! Variable value access
|
||||||
virtual TheItemType& ChangeValue (void) const
|
TheItemType& ChangeValue (void) const
|
||||||
{ return myArray->myStart[myCurrent]; }
|
{ return myArray->myStart[myCurrent]; }
|
||||||
private:
|
private:
|
||||||
Standard_Integer myCurrent; //!< Index of the current item
|
Standard_Integer myCurrent; //!< Index of the current item
|
||||||
@ -92,7 +92,6 @@ public:
|
|||||||
const Standard_Integer theRowUpper,
|
const Standard_Integer theRowUpper,
|
||||||
const Standard_Integer theColLower,
|
const Standard_Integer theColLower,
|
||||||
const Standard_Integer theColUpper) :
|
const Standard_Integer theColUpper) :
|
||||||
NCollection_BaseCollection<TheItemType> (),
|
|
||||||
myLowerRow (theRowLower),
|
myLowerRow (theRowLower),
|
||||||
myUpperRow (theRowUpper),
|
myUpperRow (theRowUpper),
|
||||||
myLowerCol (theColLower),
|
myLowerCol (theColLower),
|
||||||
@ -102,7 +101,6 @@ public:
|
|||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
NCollection_Array2 (const NCollection_Array2& theOther) :
|
NCollection_Array2 (const NCollection_Array2& theOther) :
|
||||||
NCollection_BaseCollection<TheItemType> (),
|
|
||||||
myLowerRow (theOther.LowerRow()),
|
myLowerRow (theOther.LowerRow()),
|
||||||
myUpperRow (theOther.UpperRow()),
|
myUpperRow (theOther.UpperRow()),
|
||||||
myLowerCol (theOther.LowerCol()),
|
myLowerCol (theOther.LowerCol()),
|
||||||
@ -119,7 +117,6 @@ public:
|
|||||||
const Standard_Integer theRowUpper,
|
const Standard_Integer theRowUpper,
|
||||||
const Standard_Integer theColLower,
|
const Standard_Integer theColLower,
|
||||||
const Standard_Integer theColUpper) :
|
const Standard_Integer theColUpper) :
|
||||||
NCollection_BaseCollection<TheItemType> (),
|
|
||||||
myLowerRow (theRowLower),
|
myLowerRow (theRowLower),
|
||||||
myUpperRow (theRowUpper),
|
myUpperRow (theRowUpper),
|
||||||
myLowerCol (theColLower),
|
myLowerCol (theColLower),
|
||||||
@ -139,7 +136,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Size (number of items)
|
//! Size (number of items)
|
||||||
virtual Standard_Integer Size (void) const
|
Standard_Integer Size (void) const
|
||||||
{ return Length(); }
|
{ return Length(); }
|
||||||
//! Length (number of items)
|
//! Length (number of items)
|
||||||
Standard_Integer Length (void) const
|
Standard_Integer Length (void) const
|
||||||
@ -169,28 +166,8 @@ public:
|
|||||||
Standard_Boolean IsDeletable (void) const
|
Standard_Boolean IsDeletable (void) const
|
||||||
{ return myDeletable; }
|
{ return myDeletable; }
|
||||||
|
|
||||||
//! Assign
|
//! Assignment
|
||||||
// Copies items from the other collection into the allocated
|
NCollection_Array2& Assign (const NCollection_Array2& theOther)
|
||||||
// storage. Raises an exception when sizes differ.
|
|
||||||
virtual void Assign (const NCollection_BaseCollection<TheItemType>& theOther)
|
|
||||||
{
|
|
||||||
if (&theOther == this)
|
|
||||||
return;
|
|
||||||
#if !defined No_Exception && !defined No_Standard_DimensionMismatch
|
|
||||||
if (Length() != theOther.Size())
|
|
||||||
Standard_DimensionMismatch::Raise ("NCollection_Array2::Assign");
|
|
||||||
#endif
|
|
||||||
TYPENAME NCollection_BaseCollection<TheItemType>::Iterator& anIter2 =
|
|
||||||
theOther.CreateIterator();
|
|
||||||
const TheItemType* pEnd = myStart+Length();
|
|
||||||
for (TheItemType* pItem=myStart;
|
|
||||||
pItem < pEnd;
|
|
||||||
pItem++, anIter2.Next())
|
|
||||||
*pItem = anIter2.Value();
|
|
||||||
}
|
|
||||||
|
|
||||||
//! operator= (array to array)
|
|
||||||
NCollection_Array2& operator= (const NCollection_Array2& theOther)
|
|
||||||
{
|
{
|
||||||
if (&theOther == this)
|
if (&theOther == this)
|
||||||
return *this;
|
return *this;
|
||||||
@ -206,6 +183,12 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Assignment operator
|
||||||
|
NCollection_Array2& operator= (const NCollection_Array2& theOther)
|
||||||
|
{
|
||||||
|
return Assign (theOther);
|
||||||
|
}
|
||||||
|
|
||||||
//! Constant value access
|
//! Constant value access
|
||||||
const TheItemType& Value (const Standard_Integer theRow,
|
const TheItemType& Value (const Standard_Integer theRow,
|
||||||
const Standard_Integer theCol) const
|
const Standard_Integer theCol) const
|
||||||
@ -299,11 +282,6 @@ public:
|
|||||||
myData = pTable - myLowerRow;
|
myData = pTable - myLowerRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Creates Iterator for use on BaseCollection
|
|
||||||
virtual TYPENAME NCollection_BaseCollection<TheItemType>::Iterator&
|
|
||||||
CreateIterator(void) const
|
|
||||||
{ return *(new (this->IterAllocator()) Iterator(*this)); }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ---------- PROTECTED FIELDS -----------
|
// ---------- PROTECTED FIELDS -----------
|
||||||
Standard_Integer myLowerRow;
|
Standard_Integer myLowerRow;
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
// Purpose: Implementation of the BaseAllocator class
|
// Purpose: Implementation of the BaseAllocator class
|
||||||
|
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
#include <NCollection_BaseAllocator.hxx>
|
||||||
|
#include <NCollection_IncAllocator.hxx>
|
||||||
#include <NCollection_DataMap.hxx>
|
#include <NCollection_DataMap.hxx>
|
||||||
#include <NCollection_Map.hxx>
|
#include <NCollection_Map.hxx>
|
||||||
#include <NCollection_List.hxx>
|
#include <NCollection_List.hxx>
|
||||||
|
@ -1,129 +0,0 @@
|
|||||||
// Created on: 2002-04-09
|
|
||||||
// Created by: Alexander KARTOMIN (akm)
|
|
||||||
// Copyright (c) 2002-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 NCollection_BaseCollection_HeaderFile
|
|
||||||
#define NCollection_BaseCollection_HeaderFile
|
|
||||||
|
|
||||||
#include <NCollection_IncAllocator.hxx>
|
|
||||||
#include <NCollection_DefineAlloc.hxx>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Purpose: NCollection_BaseCollection is the base abstract class for
|
|
||||||
* all collection templates of this package.
|
|
||||||
* The set of collections is similar to that of TCollection.
|
|
||||||
* Also the methods of classes have mostly the same names for
|
|
||||||
* easy switch from TCollection <-> NCollection containers.
|
|
||||||
*
|
|
||||||
* NCollection is a nocdlpack, thus it is compiled without WOK.
|
|
||||||
* BaseCollection allows assigning the collections of different
|
|
||||||
* kinds (the items type being the same) with a few obvious
|
|
||||||
* exclusions - one can not assign any collection to the map
|
|
||||||
* having double data (two keys or a key plus value). Only the
|
|
||||||
* maps of the very same type may be assigned through operator=
|
|
||||||
* Said maps are: DoubleMap,
|
|
||||||
* DataMap,
|
|
||||||
* IndexedDataMap
|
|
||||||
*
|
|
||||||
* For the users needing control over the memory usage the
|
|
||||||
* allocators were added (see NCollection_BaseAllocator header)
|
|
||||||
* Others may forget it - BaseAllocator is used by default and
|
|
||||||
* then memory is managed through Standard::Allocate/::Free.
|
|
||||||
*/
|
|
||||||
template<class TheItemType> class NCollection_BaseCollection
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// **************** The interface for iterating over collections
|
|
||||||
class Iterator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Query if the end of collection is reached by iterator
|
|
||||||
virtual Standard_Boolean More(void) const=0;
|
|
||||||
//! Make a step along the collection
|
|
||||||
virtual void Next(void)=0;
|
|
||||||
//! Value inquiry
|
|
||||||
virtual const TheItemType& Value(void) const=0;
|
|
||||||
//! Value change access
|
|
||||||
virtual TheItemType& ChangeValue(void) const=0;
|
|
||||||
public:
|
|
||||||
DEFINE_STANDARD_ALLOC
|
|
||||||
DEFINE_NCOLLECTION_ALLOC
|
|
||||||
protected:
|
|
||||||
//! Empty constructor
|
|
||||||
Iterator (void) {}
|
|
||||||
//! Virtual destructor is necessary for classes with virtual methods
|
|
||||||
virtual ~Iterator (void) {}
|
|
||||||
protected:
|
|
||||||
//! operator= is prohibited
|
|
||||||
const Iterator& operator= (const Iterator&);
|
|
||||||
//! Copy constructor **
|
|
||||||
Iterator (const Iterator&) {}
|
|
||||||
}; // End of nested class Iterator
|
|
||||||
|
|
||||||
public:
|
|
||||||
// ---------- PUBLIC METHODS ------------
|
|
||||||
|
|
||||||
//! Common for all collections constructor takes care of theAllocator
|
|
||||||
NCollection_BaseCollection
|
|
||||||
(const Handle(NCollection_BaseAllocator)& theAllocator=0L)
|
|
||||||
{
|
|
||||||
if (theAllocator.IsNull())
|
|
||||||
myAllocator = NCollection_BaseAllocator::CommonBaseAllocator();
|
|
||||||
else
|
|
||||||
myAllocator = theAllocator;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Number of items
|
|
||||||
virtual Standard_Integer Size(void) const = 0;
|
|
||||||
|
|
||||||
//! Virtual assignment
|
|
||||||
virtual void Assign
|
|
||||||
(const NCollection_BaseCollection& theOther)=0;
|
|
||||||
|
|
||||||
//! Method to create iterators for base collections
|
|
||||||
virtual Iterator& CreateIterator(void) const=0;
|
|
||||||
|
|
||||||
//! Destructor - must be implemented to release the memory
|
|
||||||
virtual ~NCollection_BaseCollection (void) {}
|
|
||||||
|
|
||||||
//! Returns attached allocator
|
|
||||||
const Handle(NCollection_BaseAllocator)& Allocator() const { return myAllocator; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// --------- PROTECTED METHOD -----------
|
|
||||||
const Handle(NCollection_BaseAllocator)& IterAllocator(void) const
|
|
||||||
{
|
|
||||||
if (myIterAllocator.IsNull())
|
|
||||||
(Handle(NCollection_BaseAllocator)&) myIterAllocator =
|
|
||||||
new NCollection_IncAllocator(64);
|
|
||||||
return myIterAllocator;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Exchange allocators of two collections
|
|
||||||
void exchangeAllocators (NCollection_BaseCollection& theOther)
|
|
||||||
{
|
|
||||||
std::swap (myAllocator, theOther.myAllocator);
|
|
||||||
std::swap (myIterAllocator, theOther.myIterAllocator);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// --------- PROTECTED FIELDS -----------
|
|
||||||
Handle(NCollection_BaseAllocator) myAllocator;
|
|
||||||
private:
|
|
||||||
// ---------- PRIVATE FIELDS ------------
|
|
||||||
Handle(NCollection_BaseAllocator) myIterAllocator;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -22,16 +22,14 @@
|
|||||||
//purpose : Deletes all nodes from the list
|
//purpose : Deletes all nodes from the list
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void NCollection_BaseList::PClear
|
void NCollection_BaseList::PClear (NCollection_DelListNode fDel)
|
||||||
(NCollection_DelListNode fDel,
|
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator)
|
|
||||||
{
|
{
|
||||||
NCollection_ListNode* pCur = myFirst;
|
NCollection_ListNode* pCur = myFirst;
|
||||||
NCollection_ListNode* pNext = NULL;
|
NCollection_ListNode* pNext = NULL;
|
||||||
while(pCur)
|
while(pCur)
|
||||||
{
|
{
|
||||||
pNext = pCur->Next();
|
pNext = pCur->Next();
|
||||||
fDel (pCur,theAllocator);
|
fDel (pCur, myAllocator);
|
||||||
pCur = pNext;
|
pCur = pNext;
|
||||||
}
|
}
|
||||||
myLength = 0;
|
myLength = 0;
|
||||||
@ -115,15 +113,13 @@ void NCollection_BaseList::PPrepend (NCollection_BaseList& theOther)
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void NCollection_BaseList::PRemoveFirst
|
void NCollection_BaseList::PRemoveFirst (NCollection_DelListNode fDel)
|
||||||
(NCollection_DelListNode fDel,
|
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator)
|
|
||||||
{
|
{
|
||||||
Standard_NoSuchObject_Raise_if(IsEmpty(),
|
Standard_NoSuchObject_Raise_if(IsEmpty(),
|
||||||
"NCollection_BaseList::PRemoveFirst");
|
"NCollection_BaseList::PRemoveFirst");
|
||||||
NCollection_ListNode* pItem = myFirst;
|
NCollection_ListNode* pItem = myFirst;
|
||||||
myFirst = pItem->Next();
|
myFirst = pItem->Next();
|
||||||
fDel (pItem, theAllocator);
|
fDel (pItem, myAllocator);
|
||||||
myLength--;
|
myLength--;
|
||||||
if (myLength == 0)
|
if (myLength == 0)
|
||||||
myLast = NULL;
|
myLast = NULL;
|
||||||
@ -134,23 +130,20 @@ void NCollection_BaseList::PRemoveFirst
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void NCollection_BaseList::PRemove
|
void NCollection_BaseList::PRemove (Iterator& theIter, NCollection_DelListNode fDel)
|
||||||
(Iterator& theIter,
|
|
||||||
NCollection_DelListNode fDel,
|
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator)
|
|
||||||
{
|
{
|
||||||
Standard_NoSuchObject_Raise_if(!theIter.More(),
|
Standard_NoSuchObject_Raise_if(!theIter.More(),
|
||||||
"NCollection_BaseList::PRemove");
|
"NCollection_BaseList::PRemove");
|
||||||
if (theIter.myPrevious == NULL)
|
if (theIter.myPrevious == NULL)
|
||||||
{
|
{
|
||||||
PRemoveFirst (fDel,theAllocator);
|
PRemoveFirst (fDel);
|
||||||
theIter.myCurrent = myFirst;
|
theIter.myCurrent = myFirst;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NCollection_ListNode* pNode = (theIter.myCurrent)->Next();
|
NCollection_ListNode* pNode = (theIter.myCurrent)->Next();
|
||||||
(theIter.myPrevious)->Next() = pNode;
|
(theIter.myPrevious)->Next() = pNode;
|
||||||
fDel (theIter.myCurrent,theAllocator);
|
fDel (theIter.myCurrent, myAllocator);
|
||||||
theIter.myCurrent = pNode;
|
theIter.myCurrent = pNode;
|
||||||
if (pNode == NULL)
|
if (pNode == NULL)
|
||||||
myLast = theIter.myPrevious;
|
myLast = theIter.myPrevious;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#define NCollection_BaseList_HeaderFile
|
#define NCollection_BaseList_HeaderFile
|
||||||
|
|
||||||
#include <Standard_NoSuchObject.hxx>
|
#include <Standard_NoSuchObject.hxx>
|
||||||
|
#include <NCollection_DefineAlloc.hxx>
|
||||||
#include <NCollection_ListNode.hxx>
|
#include <NCollection_ListNode.hxx>
|
||||||
|
|
||||||
typedef void (* NCollection_DelListNode)
|
typedef void (* NCollection_DelListNode)
|
||||||
@ -34,7 +35,12 @@ typedef void (* NCollection_DelListNode)
|
|||||||
// ********************************************************** BaseList class
|
// ********************************************************** BaseList class
|
||||||
class NCollection_BaseList
|
class NCollection_BaseList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! Memory allocation
|
||||||
|
DEFINE_STANDARD_ALLOC
|
||||||
|
DEFINE_NCOLLECTION_ALLOC
|
||||||
|
|
||||||
|
public:
|
||||||
class Iterator
|
class Iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -78,7 +84,7 @@ class NCollection_BaseList
|
|||||||
}
|
}
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
//! Performs comparison of two iterators
|
//! Performs comparison of two iterators
|
||||||
virtual Standard_Boolean IsEqual (const Iterator& theOther) const
|
Standard_Boolean IsEqual (const Iterator& theOther) const
|
||||||
{
|
{
|
||||||
return *this == theOther;
|
return *this == theOther;
|
||||||
}
|
}
|
||||||
@ -113,15 +119,17 @@ class NCollection_BaseList
|
|||||||
|
|
||||||
// ******** Constructor
|
// ******** Constructor
|
||||||
// Purpose: Initializes an empty list
|
// Purpose: Initializes an empty list
|
||||||
NCollection_BaseList(void) :
|
NCollection_BaseList (const Handle(NCollection_BaseAllocator)& theAllocator=0L) :
|
||||||
myFirst(NULL),
|
myFirst(NULL),
|
||||||
myLast(NULL),
|
myLast(NULL),
|
||||||
myLength(0) {}
|
myLength(0)
|
||||||
|
{
|
||||||
|
myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
|
||||||
|
}
|
||||||
|
|
||||||
// ******** PClear
|
// ******** PClear
|
||||||
// Purpose: deletes all nodes
|
// Purpose: deletes all nodes
|
||||||
Standard_EXPORT void PClear (NCollection_DelListNode fDel,
|
Standard_EXPORT void PClear (NCollection_DelListNode fDel);
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator);
|
|
||||||
|
|
||||||
// ******** PFirst
|
// ******** PFirst
|
||||||
// Purpose: Returns pointer to the first node
|
// Purpose: Returns pointer to the first node
|
||||||
@ -162,15 +170,13 @@ class NCollection_BaseList
|
|||||||
// ******** PRemoveFirst
|
// ******** PRemoveFirst
|
||||||
// Purpose: Removes first node
|
// Purpose: Removes first node
|
||||||
Standard_EXPORT void PRemoveFirst
|
Standard_EXPORT void PRemoveFirst
|
||||||
(NCollection_DelListNode fDel,
|
(NCollection_DelListNode fDel);
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator);
|
|
||||||
|
|
||||||
// ******** PRemove
|
// ******** PRemove
|
||||||
// Purpose: Removes the node pointed by theIter[ator]
|
// Purpose: Removes the node pointed by theIter[ator]
|
||||||
Standard_EXPORT void PRemove
|
Standard_EXPORT void PRemove
|
||||||
(Iterator& theIter,
|
(Iterator& theIter,
|
||||||
NCollection_DelListNode fDel,
|
NCollection_DelListNode fDel);
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator);
|
|
||||||
|
|
||||||
// ******** PInsertBefore
|
// ******** PInsertBefore
|
||||||
// Purpose: Inserts theNode before one pointed by theIter[ator]
|
// Purpose: Inserts theNode before one pointed by theIter[ator]
|
||||||
@ -197,7 +203,8 @@ class NCollection_BaseList
|
|||||||
Standard_EXPORT void PReverse ();
|
Standard_EXPORT void PReverse ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ------------ PRIVATE FIELDS ------------
|
// ------------ PROTECTED FIELDS ------------
|
||||||
|
Handle(NCollection_BaseAllocator) myAllocator;
|
||||||
NCollection_ListNode * myFirst; // Pointer to the head
|
NCollection_ListNode * myFirst; // Pointer to the head
|
||||||
NCollection_ListNode * myLast; // Pointer to the tail
|
NCollection_ListNode * myLast; // Pointer to the tail
|
||||||
Standard_Integer myLength; // Actual length
|
Standard_Integer myLength; // Actual length
|
||||||
|
@ -27,8 +27,7 @@ Standard_Boolean NCollection_BaseMap::BeginResize
|
|||||||
(const Standard_Integer NbBuckets,
|
(const Standard_Integer NbBuckets,
|
||||||
Standard_Integer& N,
|
Standard_Integer& N,
|
||||||
NCollection_ListNode**& data1,
|
NCollection_ListNode**& data1,
|
||||||
NCollection_ListNode**& data2,
|
NCollection_ListNode**& data2) const
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator) const
|
|
||||||
{
|
{
|
||||||
if (mySaturated) return Standard_False;
|
if (mySaturated) return Standard_False;
|
||||||
N = NextPrimeForMap(NbBuckets);
|
N = NextPrimeForMap(NbBuckets);
|
||||||
@ -39,12 +38,12 @@ Standard_Boolean NCollection_BaseMap::BeginResize
|
|||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
data1 = (NCollection_ListNode **)
|
data1 = (NCollection_ListNode **)
|
||||||
theAllocator->Allocate((N+1)*sizeof(NCollection_ListNode *));
|
myAllocator->Allocate((N+1)*sizeof(NCollection_ListNode *));
|
||||||
memset(data1, 0, (N+1)*sizeof(NCollection_ListNode *));
|
memset(data1, 0, (N+1)*sizeof(NCollection_ListNode *));
|
||||||
if (isDouble)
|
if (isDouble)
|
||||||
{
|
{
|
||||||
data2 = (NCollection_ListNode **)
|
data2 = (NCollection_ListNode **)
|
||||||
theAllocator->Allocate((N+1)*sizeof(NCollection_ListNode *));
|
myAllocator->Allocate((N+1)*sizeof(NCollection_ListNode *));
|
||||||
memset(data2, 0, (N+1)*sizeof(NCollection_ListNode *));
|
memset(data2, 0, (N+1)*sizeof(NCollection_ListNode *));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -61,13 +60,12 @@ void NCollection_BaseMap::EndResize
|
|||||||
(const Standard_Integer NbBuckets,
|
(const Standard_Integer NbBuckets,
|
||||||
const Standard_Integer N,
|
const Standard_Integer N,
|
||||||
NCollection_ListNode** data1,
|
NCollection_ListNode** data1,
|
||||||
NCollection_ListNode** data2,
|
NCollection_ListNode** data2)
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator)
|
|
||||||
{
|
{
|
||||||
if (myData1)
|
if (myData1)
|
||||||
theAllocator->Free(myData1);
|
myAllocator->Free(myData1);
|
||||||
if (myData2)
|
if (myData2)
|
||||||
theAllocator->Free(myData2);
|
myAllocator->Free(myData2);
|
||||||
myNbBuckets = N;
|
myNbBuckets = N;
|
||||||
mySaturated = (myNbBuckets <= NbBuckets);
|
mySaturated = (myNbBuckets <= NbBuckets);
|
||||||
myData1 = data1;
|
myData1 = data1;
|
||||||
@ -80,10 +78,8 @@ void NCollection_BaseMap::EndResize
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void NCollection_BaseMap::Destroy
|
void NCollection_BaseMap::Destroy (NCollection_DelMapNode fDel,
|
||||||
(NCollection_DelMapNode fDel,
|
Standard_Boolean doReleaseMemory)
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator,
|
|
||||||
const Standard_Boolean doReleaseMemory)
|
|
||||||
{
|
{
|
||||||
if (!IsEmpty())
|
if (!IsEmpty())
|
||||||
{
|
{
|
||||||
@ -98,7 +94,7 @@ void NCollection_BaseMap::Destroy
|
|||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
q = (NCollection_ListNode*)p->Next();
|
q = (NCollection_ListNode*)p->Next();
|
||||||
fDel (p, theAllocator);
|
fDel (p, myAllocator);
|
||||||
p = q;
|
p = q;
|
||||||
}
|
}
|
||||||
data[i] = NULL;
|
data[i] = NULL;
|
||||||
@ -111,9 +107,9 @@ void NCollection_BaseMap::Destroy
|
|||||||
{
|
{
|
||||||
mySaturated = Standard_False;
|
mySaturated = Standard_False;
|
||||||
if (myData1)
|
if (myData1)
|
||||||
theAllocator->Free(myData1);
|
myAllocator->Free(myData1);
|
||||||
if (isDouble && myData2)
|
if (isDouble && myData2)
|
||||||
theAllocator->Free(myData2);
|
myAllocator->Free(myData2);
|
||||||
myData1 = myData2 = NULL;
|
myData1 = myData2 = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,9 @@
|
|||||||
#ifndef NCollection_BaseMap_HeaderFile
|
#ifndef NCollection_BaseMap_HeaderFile
|
||||||
#define NCollection_BaseMap_HeaderFile
|
#define NCollection_BaseMap_HeaderFile
|
||||||
|
|
||||||
#include <Standard_Boolean.hxx>
|
|
||||||
#include <Standard_Integer.hxx>
|
|
||||||
#include <Standard_OStream.hxx>
|
|
||||||
|
|
||||||
#include <Standard.hxx>
|
#include <Standard.hxx>
|
||||||
#include <Standard_Macro.hxx>
|
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
#include <NCollection_BaseAllocator.hxx>
|
||||||
|
#include <NCollection_DefineAlloc.hxx>
|
||||||
#include <NCollection_ListNode.hxx>
|
#include <NCollection_ListNode.hxx>
|
||||||
|
|
||||||
typedef void (* NCollection_DelMapNode)
|
typedef void (* NCollection_DelMapNode)
|
||||||
@ -40,7 +36,12 @@ typedef void (* NCollection_DelMapNode)
|
|||||||
|
|
||||||
class NCollection_BaseMap
|
class NCollection_BaseMap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! Memory allocation
|
||||||
|
DEFINE_STANDARD_ALLOC
|
||||||
|
DEFINE_NCOLLECTION_ALLOC
|
||||||
|
|
||||||
|
public:
|
||||||
// **************************************** Class Iterator ****************
|
// **************************************** Class Iterator ****************
|
||||||
class Iterator
|
class Iterator
|
||||||
{
|
{
|
||||||
@ -92,7 +93,7 @@ class NCollection_BaseMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Performs comparison of two iterators.
|
//! Performs comparison of two iterators.
|
||||||
virtual Standard_Boolean IsEqual (const Iterator& theOther) const
|
Standard_Boolean IsEqual (const Iterator& theOther) const
|
||||||
{
|
{
|
||||||
return myBucket == theOther.myBucket && myNode == theOther.myNode;
|
return myBucket == theOther.myBucket && myNode == theOther.myNode;
|
||||||
}
|
}
|
||||||
@ -153,29 +154,31 @@ class NCollection_BaseMap
|
|||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
NCollection_BaseMap (const Standard_Integer NbBuckets,
|
NCollection_BaseMap (const Standard_Integer NbBuckets,
|
||||||
const Standard_Boolean single) :
|
const Standard_Boolean single,
|
||||||
myData1(NULL),
|
const Handle(NCollection_BaseAllocator)& theAllocator)
|
||||||
myData2(NULL),
|
: myData1(NULL),
|
||||||
isDouble(!single),
|
myData2(NULL),
|
||||||
mySaturated(Standard_False),
|
isDouble(!single),
|
||||||
myNbBuckets(NbBuckets),
|
mySaturated(Standard_False),
|
||||||
mySize(0) {}
|
myNbBuckets(NbBuckets),
|
||||||
|
mySize(0)
|
||||||
|
{
|
||||||
|
myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
|
||||||
|
}
|
||||||
|
|
||||||
//! BeginResize
|
//! BeginResize
|
||||||
Standard_EXPORT Standard_Boolean BeginResize
|
Standard_EXPORT Standard_Boolean BeginResize
|
||||||
(const Standard_Integer NbBuckets,
|
(const Standard_Integer NbBuckets,
|
||||||
Standard_Integer& NewBuckets,
|
Standard_Integer& NewBuckets,
|
||||||
NCollection_ListNode**& data1,
|
NCollection_ListNode**& data1,
|
||||||
NCollection_ListNode**& data2,
|
NCollection_ListNode**& data2) const;
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator) const;
|
|
||||||
|
|
||||||
//! EndResize
|
//! EndResize
|
||||||
Standard_EXPORT void EndResize
|
Standard_EXPORT void EndResize
|
||||||
(const Standard_Integer NbBuckets,
|
(const Standard_Integer NbBuckets,
|
||||||
const Standard_Integer NewBuckets,
|
const Standard_Integer NewBuckets,
|
||||||
NCollection_ListNode** data1,
|
NCollection_ListNode** data1,
|
||||||
NCollection_ListNode** data2,
|
NCollection_ListNode** data2);
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator);
|
|
||||||
|
|
||||||
//! Resizable
|
//! Resizable
|
||||||
Standard_Boolean Resizable() const
|
Standard_Boolean Resizable() const
|
||||||
@ -191,9 +194,7 @@ class NCollection_BaseMap
|
|||||||
|
|
||||||
//! Destroy
|
//! Destroy
|
||||||
Standard_EXPORT void Destroy(NCollection_DelMapNode fDel,
|
Standard_EXPORT void Destroy(NCollection_DelMapNode fDel,
|
||||||
Handle(NCollection_BaseAllocator)& theAllocator,
|
Standard_Boolean doReleaseMemory = Standard_True);
|
||||||
const Standard_Boolean doReleaseMemory
|
|
||||||
= Standard_True);
|
|
||||||
|
|
||||||
//! NextPrimeForMap
|
//! NextPrimeForMap
|
||||||
Standard_EXPORT Standard_Integer NextPrimeForMap
|
Standard_EXPORT Standard_Integer NextPrimeForMap
|
||||||
@ -202,6 +203,7 @@ class NCollection_BaseMap
|
|||||||
//! Exchange content of two maps without data copying
|
//! Exchange content of two maps without data copying
|
||||||
void exchangeMapsData (NCollection_BaseMap& theOther)
|
void exchangeMapsData (NCollection_BaseMap& theOther)
|
||||||
{
|
{
|
||||||
|
std::swap (myAllocator, theOther.myAllocator);
|
||||||
std::swap (myData1, theOther.myData1);
|
std::swap (myData1, theOther.myData1);
|
||||||
std::swap (myData2, theOther.myData2);
|
std::swap (myData2, theOther.myData2);
|
||||||
//std::swap (isDouble, theOther.isDouble);
|
//std::swap (isDouble, theOther.isDouble);
|
||||||
@ -212,6 +214,7 @@ class NCollection_BaseMap
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// --------- PROTECTED FIELDS -----------
|
// --------- PROTECTED FIELDS -----------
|
||||||
|
Handle(NCollection_BaseAllocator) myAllocator;
|
||||||
NCollection_ListNode ** myData1;
|
NCollection_ListNode ** myData1;
|
||||||
NCollection_ListNode ** myData2;
|
NCollection_ListNode ** myData2;
|
||||||
|
|
||||||
@ -224,7 +227,6 @@ class NCollection_BaseMap
|
|||||||
|
|
||||||
// ---------- FRIEND CLASSES ------------
|
// ---------- FRIEND CLASSES ------------
|
||||||
friend class Iterator;
|
friend class Iterator;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,19 +20,24 @@
|
|||||||
#include <Standard_OutOfRange.hxx>
|
#include <Standard_OutOfRange.hxx>
|
||||||
#include <Standard_DomainError.hxx>
|
#include <Standard_DomainError.hxx>
|
||||||
|
|
||||||
|
inline void NCollection_BaseSequence::Nullify ()
|
||||||
|
{
|
||||||
|
myFirstItem = myLastItem = myCurrentItem = NULL;
|
||||||
|
myCurrentIndex = mySize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : ClearSeq
|
//function : ClearSeq
|
||||||
//purpose : removes all items from the current sequence
|
//purpose : removes all items from the current sequence
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void NCollection_BaseSequence::ClearSeq
|
void NCollection_BaseSequence::ClearSeq (NCollection_DelSeqNode fDel)
|
||||||
(NCollection_DelSeqNode fDel, Handle(NCollection_BaseAllocator)& theAl)
|
|
||||||
{
|
{
|
||||||
NCollection_SeqNode* p = myFirstItem;
|
NCollection_SeqNode* p = myFirstItem;
|
||||||
while (p) {
|
while (p) {
|
||||||
NCollection_SeqNode* q = p;
|
NCollection_SeqNode* q = p;
|
||||||
p = p->Next();
|
p = p->Next();
|
||||||
fDel (q, theAl);
|
fDel (q, myAllocator);
|
||||||
}
|
}
|
||||||
Nullify();
|
Nullify();
|
||||||
}
|
}
|
||||||
@ -324,8 +329,7 @@ void NCollection_BaseSequence::PSplit (const Standard_Integer theIndex,
|
|||||||
|
|
||||||
void NCollection_BaseSequence::RemoveSeq
|
void NCollection_BaseSequence::RemoveSeq
|
||||||
(NCollection_BaseSequence::Iterator& thePosition,
|
(NCollection_BaseSequence::Iterator& thePosition,
|
||||||
NCollection_DelSeqNode fDel,
|
NCollection_DelSeqNode fDel)
|
||||||
Handle(NCollection_BaseAllocator)& theAl)
|
|
||||||
{
|
{
|
||||||
NCollection_SeqNode * aPos = thePosition.myCurrent;
|
NCollection_SeqNode * aPos = thePosition.myCurrent;
|
||||||
if (aPos == NULL)
|
if (aPos == NULL)
|
||||||
@ -346,7 +350,7 @@ void NCollection_BaseSequence::RemoveSeq
|
|||||||
myCurrentItem = myLastItem;
|
myCurrentItem = myLastItem;
|
||||||
myCurrentIndex = mySize;
|
myCurrentIndex = mySize;
|
||||||
|
|
||||||
fDel (aPos, theAl);
|
fDel (aPos, myAllocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -354,10 +358,8 @@ void NCollection_BaseSequence::RemoveSeq
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void NCollection_BaseSequence::RemoveSeq
|
void NCollection_BaseSequence::RemoveSeq (const Standard_Integer theIndex,
|
||||||
(const Standard_Integer theIndex,
|
NCollection_DelSeqNode fDel)
|
||||||
NCollection_DelSeqNode fDel,
|
|
||||||
Handle(NCollection_BaseAllocator)& theAl)
|
|
||||||
{
|
{
|
||||||
Standard_OutOfRange_Raise_if (theIndex <= 0 || theIndex > mySize, "");
|
Standard_OutOfRange_Raise_if (theIndex <= 0 || theIndex > mySize, "");
|
||||||
|
|
||||||
@ -381,7 +383,7 @@ void NCollection_BaseSequence::RemoveSeq
|
|||||||
myCurrentIndex = mySize;
|
myCurrentIndex = mySize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fDel (p, theAl);
|
fDel (p, myAllocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -389,11 +391,9 @@ void NCollection_BaseSequence::RemoveSeq
|
|||||||
//purpose : remove a set of items
|
//purpose : remove a set of items
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void NCollection_BaseSequence::RemoveSeq
|
void NCollection_BaseSequence::RemoveSeq (const Standard_Integer From,
|
||||||
(const Standard_Integer From,
|
const Standard_Integer To,
|
||||||
const Standard_Integer To,
|
NCollection_DelSeqNode fDel)
|
||||||
NCollection_DelSeqNode fDel,
|
|
||||||
Handle(NCollection_BaseAllocator)& theAl)
|
|
||||||
{
|
{
|
||||||
Standard_OutOfRange_Raise_if (From <= 0 || To > mySize || From > To, "");
|
Standard_OutOfRange_Raise_if (From <= 0 || To > mySize || From > To, "");
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ void NCollection_BaseSequence::RemoveSeq
|
|||||||
for (Standard_Integer i = From; i <= To; i++) {
|
for (Standard_Integer i = From; i <= To; i++) {
|
||||||
NCollection_SeqNode * tmp = pfrom;
|
NCollection_SeqNode * tmp = pfrom;
|
||||||
pfrom = pfrom->Next();
|
pfrom = pfrom->Next();
|
||||||
fDel (tmp, theAl);
|
fDel (tmp, myAllocator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,16 @@
|
|||||||
|
|
||||||
#include <Standard.hxx>
|
#include <Standard.hxx>
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
#include <NCollection_BaseAllocator.hxx>
|
||||||
|
#include <NCollection_DefineAlloc.hxx>
|
||||||
|
|
||||||
// **************************************** Class SeqNode ********************
|
// **************************************** Class SeqNode ********************
|
||||||
|
|
||||||
class NCollection_SeqNode
|
class NCollection_SeqNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// define new operator for use with NCollection allocators
|
||||||
|
DEFINE_NCOLLECTION_ALLOC
|
||||||
|
public:
|
||||||
NCollection_SeqNode () : myNext (NULL), myPrevious (NULL) {}
|
NCollection_SeqNode () : myNext (NULL), myPrevious (NULL) {}
|
||||||
NCollection_SeqNode * Next () const { return myNext; }
|
NCollection_SeqNode * Next () const { return myNext; }
|
||||||
NCollection_SeqNode * Previous () const { return myPrevious; }
|
NCollection_SeqNode * Previous () const { return myPrevious; }
|
||||||
@ -44,7 +48,12 @@ typedef void (* NCollection_DelSeqNode)
|
|||||||
*/
|
*/
|
||||||
class NCollection_BaseSequence
|
class NCollection_BaseSequence
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! Memory allocation
|
||||||
|
DEFINE_STANDARD_ALLOC
|
||||||
|
DEFINE_NCOLLECTION_ALLOC
|
||||||
|
|
||||||
|
public:
|
||||||
class Iterator
|
class Iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -96,9 +105,17 @@ class NCollection_BaseSequence
|
|||||||
protected:
|
protected:
|
||||||
// Methods PROTECTED
|
// Methods PROTECTED
|
||||||
//
|
//
|
||||||
inline NCollection_BaseSequence ();
|
NCollection_BaseSequence (const Handle(NCollection_BaseAllocator)& theAllocator) :
|
||||||
Standard_EXPORT void ClearSeq (NCollection_DelSeqNode fDel,
|
myFirstItem (NULL),
|
||||||
Handle(NCollection_BaseAllocator)& theAl);
|
myLastItem (NULL),
|
||||||
|
myCurrentItem (NULL),
|
||||||
|
myCurrentIndex (0),
|
||||||
|
mySize (0)
|
||||||
|
{
|
||||||
|
myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_EXPORT void ClearSeq (NCollection_DelSeqNode fDel);
|
||||||
Standard_EXPORT void PAppend (NCollection_SeqNode *);
|
Standard_EXPORT void PAppend (NCollection_SeqNode *);
|
||||||
Standard_EXPORT void PAppend (NCollection_BaseSequence& S);
|
Standard_EXPORT void PAppend (NCollection_BaseSequence& S);
|
||||||
Standard_EXPORT void PPrepend (NCollection_SeqNode *);
|
Standard_EXPORT void PPrepend (NCollection_SeqNode *);
|
||||||
@ -112,15 +129,12 @@ class NCollection_BaseSequence
|
|||||||
Standard_EXPORT void PSplit (const Standard_Integer Index,
|
Standard_EXPORT void PSplit (const Standard_Integer Index,
|
||||||
NCollection_BaseSequence& Sub);
|
NCollection_BaseSequence& Sub);
|
||||||
Standard_EXPORT void RemoveSeq (Iterator& thePosition,
|
Standard_EXPORT void RemoveSeq (Iterator& thePosition,
|
||||||
NCollection_DelSeqNode fDel,
|
NCollection_DelSeqNode fDel);
|
||||||
Handle(NCollection_BaseAllocator)& theAl);
|
|
||||||
Standard_EXPORT void RemoveSeq (const Standard_Integer Index,
|
Standard_EXPORT void RemoveSeq (const Standard_Integer Index,
|
||||||
NCollection_DelSeqNode fDel,
|
NCollection_DelSeqNode fDel);
|
||||||
Handle(NCollection_BaseAllocator)& theAl);
|
|
||||||
Standard_EXPORT void RemoveSeq (const Standard_Integer From,
|
Standard_EXPORT void RemoveSeq (const Standard_Integer From,
|
||||||
const Standard_Integer To,
|
const Standard_Integer To,
|
||||||
NCollection_DelSeqNode fDel,
|
NCollection_DelSeqNode fDel);
|
||||||
Handle(NCollection_BaseAllocator)& theAl);
|
|
||||||
Standard_EXPORT void PReverse ();
|
Standard_EXPORT void PReverse ();
|
||||||
Standard_EXPORT void PExchange (const Standard_Integer I,
|
Standard_EXPORT void PExchange (const Standard_Integer I,
|
||||||
const Standard_Integer J) ;
|
const Standard_Integer J) ;
|
||||||
@ -130,6 +144,7 @@ class NCollection_BaseSequence
|
|||||||
protected:
|
protected:
|
||||||
// Fields PROTECTED
|
// Fields PROTECTED
|
||||||
//
|
//
|
||||||
|
Handle(NCollection_BaseAllocator) myAllocator;
|
||||||
NCollection_SeqNode* myFirstItem;
|
NCollection_SeqNode* myFirstItem;
|
||||||
NCollection_SeqNode* myLastItem;
|
NCollection_SeqNode* myLastItem;
|
||||||
NCollection_SeqNode* myCurrentItem;
|
NCollection_SeqNode* myCurrentItem;
|
||||||
@ -141,21 +156,8 @@ class NCollection_BaseSequence
|
|||||||
//
|
//
|
||||||
Standard_EXPORT NCollection_BaseSequence
|
Standard_EXPORT NCollection_BaseSequence
|
||||||
(const NCollection_BaseSequence& Other);
|
(const NCollection_BaseSequence& Other);
|
||||||
inline void Nullify ();
|
inline void Nullify ();
|
||||||
friend class Iterator;
|
friend class Iterator;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline NCollection_BaseSequence::NCollection_BaseSequence ()
|
|
||||||
: myFirstItem (NULL),
|
|
||||||
myLastItem (NULL),
|
|
||||||
myCurrentItem (NULL),
|
|
||||||
myCurrentIndex (0),
|
|
||||||
mySize (0) {}
|
|
||||||
|
|
||||||
inline void NCollection_BaseSequence::Nullify ()
|
|
||||||
{
|
|
||||||
myFirstItem = myLastItem = myCurrentItem = NULL;
|
|
||||||
myCurrentIndex = mySize = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -63,12 +63,11 @@ void NCollection_BaseVector::Iterator::initV (const NCollection_BaseVector& theV
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
NCollection_BaseVector::MemBlock* NCollection_BaseVector
|
NCollection_BaseVector::MemBlock* NCollection_BaseVector
|
||||||
::allocMemBlocks (Handle(NCollection_BaseAllocator)& theAllocator,
|
::allocMemBlocks (const Standard_Integer theCapacity,
|
||||||
const Standard_Integer theCapacity,
|
|
||||||
MemBlock* theSource,
|
MemBlock* theSource,
|
||||||
const Standard_Integer theSourceSize)
|
const Standard_Integer theSourceSize)
|
||||||
{
|
{
|
||||||
MemBlock* aData = (MemBlock* )theAllocator->Allocate (theCapacity * sizeof(MemBlock));
|
MemBlock* aData = (MemBlock* )myAllocator->Allocate (theCapacity * sizeof(MemBlock));
|
||||||
|
|
||||||
// copy content from source array
|
// copy content from source array
|
||||||
Standard_Integer aCapacity = 0;
|
Standard_Integer aCapacity = 0;
|
||||||
@ -76,7 +75,7 @@ NCollection_BaseVector::MemBlock* NCollection_BaseVector
|
|||||||
{
|
{
|
||||||
memcpy (aData, theSource, theSourceSize * sizeof(MemBlock));
|
memcpy (aData, theSource, theSourceSize * sizeof(MemBlock));
|
||||||
aCapacity = theSourceSize;
|
aCapacity = theSourceSize;
|
||||||
theAllocator->Free (theSource);
|
myAllocator->Free (theSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nullify newly allocated blocks
|
// Nullify newly allocated blocks
|
||||||
@ -110,8 +109,7 @@ void NCollection_BaseVector::Clear()
|
|||||||
//purpose : returns the pointer where the new data item is supposed to be put
|
//purpose : returns the pointer where the new data item is supposed to be put
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void* NCollection_BaseVector::expandV (Handle(NCollection_BaseAllocator)& theAllocator,
|
void* NCollection_BaseVector::expandV (const Standard_Integer theIndex)
|
||||||
const Standard_Integer theIndex)
|
|
||||||
{
|
{
|
||||||
const Standard_Integer aNewLength = theIndex + 1;
|
const Standard_Integer aNewLength = theIndex + 1;
|
||||||
if (myNBlocks > 0)
|
if (myNBlocks > 0)
|
||||||
@ -140,7 +138,7 @@ void* NCollection_BaseVector::expandV (Handle(NCollection_BaseAllocator)& theAll
|
|||||||
// Reallocate the array myData
|
// Reallocate the array myData
|
||||||
do myCapacity += GetCapacity(myIncrement); while (myCapacity <= nNewBlock);
|
do myCapacity += GetCapacity(myIncrement); while (myCapacity <= nNewBlock);
|
||||||
|
|
||||||
myData = allocMemBlocks (theAllocator, myCapacity, myData, myNBlocks);
|
myData = allocMemBlocks (myCapacity, myData, myNBlocks);
|
||||||
}
|
}
|
||||||
if (myNBlocks > 0)
|
if (myNBlocks > 0)
|
||||||
{
|
{
|
||||||
|
@ -17,15 +17,11 @@
|
|||||||
#define NCollection_BaseVector_HeaderFile
|
#define NCollection_BaseVector_HeaderFile
|
||||||
|
|
||||||
#include <Standard_TypeDef.hxx>
|
#include <Standard_TypeDef.hxx>
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include <Standard_OutOfRange.hxx>
|
#include <Standard_OutOfRange.hxx>
|
||||||
|
#include <NCollection_BaseAllocator.hxx>
|
||||||
|
#include <NCollection_DefineAlloc.hxx>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#include <stddef.h>
|
||||||
#pragma warning(push, 1)
|
|
||||||
#pragma warning(disable:4355)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// this value defines the number of blocks that are reserved
|
// this value defines the number of blocks that are reserved
|
||||||
// when the capacity of vector is increased
|
// when the capacity of vector is increased
|
||||||
@ -37,6 +33,10 @@ inline Standard_Integer GetCapacity (const Standard_Integer theIncrement)
|
|||||||
//! Class NCollection_BaseVector - base for NCollection_Vector template
|
//! Class NCollection_BaseVector - base for NCollection_Vector template
|
||||||
class NCollection_BaseVector
|
class NCollection_BaseVector
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
//! Memory allocation
|
||||||
|
DEFINE_STANDARD_ALLOC
|
||||||
|
DEFINE_NCOLLECTION_ALLOC
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -112,14 +112,14 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void offsetV (Standard_Integer theOffset)
|
void offsetV (Standard_Integer theOffset)
|
||||||
{
|
{
|
||||||
const Standard_Integer anIndex = myCurIndex + myICurBlock * myVector->myIncrement + theOffset;
|
const Standard_Integer anIndex = myCurIndex + myICurBlock * myVector->myIncrement + theOffset;
|
||||||
myICurBlock = anIndex / myVector->myIncrement;
|
myICurBlock = anIndex / myVector->myIncrement;
|
||||||
myCurIndex = anIndex % myVector->myIncrement;
|
myCurIndex = anIndex % myVector->myIncrement;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Standard_Integer differV (const Iterator& theOther) const
|
Standard_Integer differV (const Iterator& theOther) const
|
||||||
{
|
{
|
||||||
return (myCurIndex - theOther.myCurIndex) + (myICurBlock - theOther.myICurBlock) * myVector->myIncrement;
|
return (myCurIndex - theOther.myCurIndex) + (myICurBlock - theOther.myICurBlock) * myVector->myIncrement;
|
||||||
}
|
}
|
||||||
@ -144,19 +144,17 @@ protected: //! @name Block initializer
|
|||||||
const Standard_Integer theSize);
|
const Standard_Integer theSize);
|
||||||
|
|
||||||
//! Allocate memory for array of memory blocks.
|
//! Allocate memory for array of memory blocks.
|
||||||
//! @param theAllocator Memory allocator to use
|
|
||||||
//! @param theCapacity Number of memory blocks in array
|
//! @param theCapacity Number of memory blocks in array
|
||||||
//! @param theSource Original array of memory blocks, will be automatically deallocated
|
//! @param theSource Original array of memory blocks, will be automatically deallocated
|
||||||
//! @param theSourceSize Number of memory blocks in original array
|
//! @param theSourceSize Number of memory blocks in original array
|
||||||
Standard_EXPORT static MemBlock* allocMemBlocks (Handle(NCollection_BaseAllocator)& theAllocator,
|
Standard_EXPORT MemBlock* allocMemBlocks (const Standard_Integer theCapacity,
|
||||||
const Standard_Integer theCapacity,
|
MemBlock* theSource = NULL,
|
||||||
MemBlock* theSource = NULL,
|
const Standard_Integer theSourceSize = 0);
|
||||||
const Standard_Integer theSourceSize = 0);
|
|
||||||
|
|
||||||
protected: //! @name protected methods
|
protected: //! @name protected methods
|
||||||
|
|
||||||
//! Empty constructor
|
//! Empty constructor
|
||||||
NCollection_BaseVector (Handle(NCollection_BaseAllocator)& theAllocator,
|
NCollection_BaseVector (const Handle(NCollection_BaseAllocator)& theAllocator,
|
||||||
initMemBlocks_t theInitBlocks,
|
initMemBlocks_t theInitBlocks,
|
||||||
const size_t theSize,
|
const size_t theSize,
|
||||||
const Standard_Integer theInc)
|
const Standard_Integer theInc)
|
||||||
@ -165,11 +163,14 @@ protected: //! @name protected methods
|
|||||||
myLength (0),
|
myLength (0),
|
||||||
myCapacity (GetCapacity (myIncrement)),
|
myCapacity (GetCapacity (myIncrement)),
|
||||||
myNBlocks (0),
|
myNBlocks (0),
|
||||||
myData (allocMemBlocks (theAllocator, myCapacity)),
|
myInitBlocks (theInitBlocks)
|
||||||
myInitBlocks (theInitBlocks) {}
|
{
|
||||||
|
myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
|
||||||
|
myData = allocMemBlocks (myCapacity);
|
||||||
|
}
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
NCollection_BaseVector (Handle(NCollection_BaseAllocator)& theAllocator,
|
NCollection_BaseVector (const Handle(NCollection_BaseAllocator)& theAllocator,
|
||||||
initMemBlocks_t theInitBlocks,
|
initMemBlocks_t theInitBlocks,
|
||||||
const NCollection_BaseVector& theOther)
|
const NCollection_BaseVector& theOther)
|
||||||
: myItemSize (theOther.myItemSize),
|
: myItemSize (theOther.myItemSize),
|
||||||
@ -177,12 +178,14 @@ protected: //! @name protected methods
|
|||||||
myLength (theOther.myLength),
|
myLength (theOther.myLength),
|
||||||
myCapacity (GetCapacity(myIncrement) + theOther.myLength / theOther.myIncrement),
|
myCapacity (GetCapacity(myIncrement) + theOther.myLength / theOther.myIncrement),
|
||||||
myNBlocks (1 + (theOther.myLength - 1)/theOther.myIncrement),
|
myNBlocks (1 + (theOther.myLength - 1)/theOther.myIncrement),
|
||||||
myData (allocMemBlocks (theAllocator, myCapacity)),
|
myInitBlocks (theInitBlocks)
|
||||||
myInitBlocks (theInitBlocks) {}
|
{
|
||||||
|
myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
|
||||||
|
myData = allocMemBlocks (myCapacity);
|
||||||
|
}
|
||||||
|
|
||||||
//! @return pointer to memory where to put the new item
|
//! @return pointer to memory where to put the new item
|
||||||
Standard_EXPORT void* expandV (Handle(NCollection_BaseAllocator)& theAllocator,
|
Standard_EXPORT void* expandV (const Standard_Integer theIndex);
|
||||||
const Standard_Integer theIndex);
|
|
||||||
|
|
||||||
//! Locate the memory holding the desired value
|
//! Locate the memory holding the desired value
|
||||||
inline void* findV (const Standard_Integer theIndex) const
|
inline void* findV (const Standard_Integer theIndex) const
|
||||||
@ -198,8 +201,9 @@ public: //! @name public API
|
|||||||
//! Empty the vector of its objects
|
//! Empty the vector of its objects
|
||||||
Standard_EXPORT void Clear();
|
Standard_EXPORT void Clear();
|
||||||
|
|
||||||
protected: //! @name Private fields
|
protected: //! @name Protected fields
|
||||||
|
|
||||||
|
Handle(NCollection_BaseAllocator) myAllocator;
|
||||||
size_t myItemSize;
|
size_t myItemSize;
|
||||||
Standard_Integer myIncrement;
|
Standard_Integer myIncrement;
|
||||||
Standard_Integer myLength;
|
Standard_Integer myLength;
|
||||||
@ -211,11 +215,6 @@ protected: //! @name Private fields
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
friend class Iterator;
|
friend class Iterator;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // NCollection_BaseVector_HeaderFile
|
#endif // NCollection_BaseVector_HeaderFile
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Destructor.
|
//! Destructor.
|
||||||
virtual ~NCollection_Buffer()
|
~NCollection_Buffer()
|
||||||
{
|
{
|
||||||
Free();
|
Free();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <NCollection_List.hxx>
|
#include <NCollection_List.hxx>
|
||||||
#include <NCollection_Map.hxx>
|
#include <NCollection_Map.hxx>
|
||||||
#include <NCollection_DataMap.hxx>
|
#include <NCollection_DataMap.hxx>
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
#include <NCollection_IncAllocator.hxx>
|
||||||
#include <NCollection_TypeDef.hxx>
|
#include <NCollection_TypeDef.hxx>
|
||||||
|
|
||||||
//! Auxiliary enumeration serving as responce from method Inspect
|
//! Auxiliary enumeration serving as responce from method Inspect
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#ifndef NCollection_DataMap_HeaderFile
|
#ifndef NCollection_DataMap_HeaderFile
|
||||||
#define NCollection_DataMap_HeaderFile
|
#define NCollection_DataMap_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_BaseCollection.hxx>
|
|
||||||
#include <NCollection_BaseMap.hxx>
|
#include <NCollection_BaseMap.hxx>
|
||||||
#include <NCollection_TListNode.hxx>
|
#include <NCollection_TListNode.hxx>
|
||||||
#include <NCollection_StlIterator.hxx>
|
#include <NCollection_StlIterator.hxx>
|
||||||
@ -45,10 +44,8 @@
|
|||||||
|
|
||||||
template < class TheKeyType,
|
template < class TheKeyType,
|
||||||
class TheItemType,
|
class TheItemType,
|
||||||
class Hasher = NCollection_DefaultHasher<TheKeyType> > class NCollection_DataMap
|
class Hasher = NCollection_DefaultHasher<TheKeyType> >
|
||||||
|
class NCollection_DataMap : public NCollection_BaseMap
|
||||||
: public NCollection_BaseCollection<TheItemType>,
|
|
||||||
public NCollection_BaseMap
|
|
||||||
{
|
{
|
||||||
// **************** Adaptation of the TListNode to the DATAmap
|
// **************** Adaptation of the TListNode to the DATAmap
|
||||||
public:
|
public:
|
||||||
@ -65,7 +62,7 @@ template < class TheKeyType,
|
|||||||
const TheKeyType& Key (void) const
|
const TheKeyType& Key (void) const
|
||||||
{ return myKey; }
|
{ return myKey; }
|
||||||
|
|
||||||
//! Static deleter to be passed to BaseList
|
//! Static deleter to be passed to BaseMap
|
||||||
static void delNode (NCollection_ListNode * theNode,
|
static void delNode (NCollection_ListNode * theNode,
|
||||||
Handle(NCollection_BaseAllocator)& theAl)
|
Handle(NCollection_BaseAllocator)& theAl)
|
||||||
{
|
{
|
||||||
@ -79,9 +76,7 @@ template < class TheKeyType,
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// **************** Implementation of the Iterator interface.
|
// **************** Implementation of the Iterator interface.
|
||||||
class Iterator
|
class Iterator : public NCollection_BaseMap::Iterator
|
||||||
: public NCollection_BaseCollection<TheItemType>::Iterator,
|
|
||||||
public NCollection_BaseMap::Iterator
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Empty constructor
|
//! Empty constructor
|
||||||
@ -91,13 +86,13 @@ template < class TheKeyType,
|
|||||||
Iterator (const NCollection_DataMap& theMap) :
|
Iterator (const NCollection_DataMap& theMap) :
|
||||||
NCollection_BaseMap::Iterator(theMap) {}
|
NCollection_BaseMap::Iterator(theMap) {}
|
||||||
//! Query if the end of collection is reached by iterator
|
//! Query if the end of collection is reached by iterator
|
||||||
virtual Standard_Boolean More(void) const
|
Standard_Boolean More(void) const
|
||||||
{ return PMore(); }
|
{ return PMore(); }
|
||||||
//! Make a step along the collection
|
//! Make a step along the collection
|
||||||
virtual void Next(void)
|
void Next(void)
|
||||||
{ PNext(); }
|
{ PNext(); }
|
||||||
//! Value inquiry
|
//! Value inquiry
|
||||||
virtual const TheItemType& Value(void) const
|
const TheItemType& Value(void) const
|
||||||
{
|
{
|
||||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||||
if (!More())
|
if (!More())
|
||||||
@ -106,7 +101,7 @@ template < class TheKeyType,
|
|||||||
return ((DataMapNode *) myNode)->Value();
|
return ((DataMapNode *) myNode)->Value();
|
||||||
}
|
}
|
||||||
//! Value change access
|
//! Value change access
|
||||||
virtual TheItemType& ChangeValue(void) const
|
TheItemType& ChangeValue(void) const
|
||||||
{
|
{
|
||||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||||
if (!More())
|
if (!More())
|
||||||
@ -149,33 +144,22 @@ template < class TheKeyType,
|
|||||||
//! Constructor
|
//! Constructor
|
||||||
NCollection_DataMap (const Standard_Integer NbBuckets=1,
|
NCollection_DataMap (const Standard_Integer NbBuckets=1,
|
||||||
const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
|
const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
|
||||||
: NCollection_BaseCollection<TheItemType>(theAllocator),
|
: NCollection_BaseMap (NbBuckets, Standard_True, theAllocator) {}
|
||||||
NCollection_BaseMap (NbBuckets, Standard_True) {}
|
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
NCollection_DataMap (const NCollection_DataMap& theOther)
|
NCollection_DataMap (const NCollection_DataMap& theOther)
|
||||||
: NCollection_BaseCollection<TheItemType>(theOther.myAllocator),
|
: NCollection_BaseMap (theOther.NbBuckets(), Standard_True, theOther.myAllocator)
|
||||||
NCollection_BaseMap (theOther.NbBuckets(), Standard_True)
|
|
||||||
{ *this = theOther; }
|
{ *this = theOther; }
|
||||||
|
|
||||||
//! Assign another collection
|
|
||||||
virtual void Assign(const NCollection_BaseCollection<TheItemType>& theOther)
|
|
||||||
{
|
|
||||||
if (this == &theOther)
|
|
||||||
return;
|
|
||||||
Standard_TypeMismatch::Raise ("NCollection_DataMap::Assign impossible");
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Exchange the content of two maps without re-allocations.
|
//! Exchange the content of two maps without re-allocations.
|
||||||
//! Notice that allocators will be swapped as well!
|
//! Notice that allocators will be swapped as well!
|
||||||
void Exchange (NCollection_DataMap& theOther)
|
void Exchange (NCollection_DataMap& theOther)
|
||||||
{
|
{
|
||||||
this->exchangeAllocators (theOther);
|
this->exchangeMapsData (theOther);
|
||||||
this->exchangeMapsData (theOther);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! = another map
|
//! Assignment
|
||||||
NCollection_DataMap& operator= (const NCollection_DataMap& theOther)
|
NCollection_DataMap& Assign (const NCollection_DataMap& theOther)
|
||||||
{
|
{
|
||||||
if (this == &theOther)
|
if (this == &theOther)
|
||||||
return *this;
|
return *this;
|
||||||
@ -188,13 +172,19 @@ template < class TheKeyType,
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Assignment operator
|
||||||
|
NCollection_DataMap& operator= (const NCollection_DataMap& theOther)
|
||||||
|
{
|
||||||
|
return Assign (theOther);
|
||||||
|
}
|
||||||
|
|
||||||
//! ReSize
|
//! ReSize
|
||||||
void ReSize (const Standard_Integer N)
|
void ReSize (const Standard_Integer N)
|
||||||
{
|
{
|
||||||
NCollection_ListNode** newdata = NULL;
|
NCollection_ListNode** newdata = NULL;
|
||||||
NCollection_ListNode** dummy = NULL;
|
NCollection_ListNode** dummy = NULL;
|
||||||
Standard_Integer newBuck;
|
Standard_Integer newBuck;
|
||||||
if (BeginResize (N, newBuck, newdata, dummy, this->myAllocator))
|
if (BeginResize (N, newBuck, newdata, dummy))
|
||||||
{
|
{
|
||||||
if (myData1)
|
if (myData1)
|
||||||
{
|
{
|
||||||
@ -217,7 +207,7 @@ template < class TheKeyType,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndResize (N, newBuck, newdata, dummy, this->myAllocator);
|
EndResize (N, newBuck, newdata, dummy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +347,7 @@ template < class TheKeyType,
|
|||||||
//! Clear data. If doReleaseMemory is false then the table of
|
//! Clear data. If doReleaseMemory is false then the table of
|
||||||
//! buckets is not released and will be reused.
|
//! buckets is not released and will be reused.
|
||||||
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
|
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
|
||||||
{ Destroy (DataMapNode::delNode, this->myAllocator, doReleaseMemory); }
|
{ Destroy (DataMapNode::delNode, doReleaseMemory); }
|
||||||
|
|
||||||
//! Clear data and reset allocator
|
//! Clear data and reset allocator
|
||||||
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
|
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
|
||||||
@ -372,17 +362,8 @@ template < class TheKeyType,
|
|||||||
{ Clear(); }
|
{ Clear(); }
|
||||||
|
|
||||||
//! Size
|
//! Size
|
||||||
virtual Standard_Integer Size(void) const
|
Standard_Integer Size(void) const
|
||||||
{ return Extent(); }
|
{ return Extent(); }
|
||||||
|
|
||||||
private:
|
|
||||||
// ----------- PRIVATE METHODS -----------
|
|
||||||
|
|
||||||
//! Creates Iterator for use on BaseCollection
|
|
||||||
virtual TYPENAME NCollection_BaseCollection<TheItemType>::Iterator&
|
|
||||||
CreateIterator(void) const
|
|
||||||
{ return *(new (this->IterAllocator()) Iterator(*this)); }
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
#ifndef NCollection_DefineArray1_HeaderFile
|
#ifndef NCollection_DefineArray1_HeaderFile
|
||||||
#define NCollection_DefineArray1_HeaderFile
|
#define NCollection_DefineArray1_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_Array1.hxx>
|
#include <NCollection_Array1.hxx>
|
||||||
|
|
||||||
// *********************************************** Template for Array1 class
|
// *********************************************** Template for Array1 class
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#ifndef NCollection_DefineArray2_HeaderFile
|
#ifndef NCollection_DefineArray2_HeaderFile
|
||||||
#define NCollection_DefineArray2_HeaderFile
|
#define NCollection_DefineArray2_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_Array2.hxx>
|
#include <NCollection_Array2.hxx>
|
||||||
|
|
||||||
// *********************************************** Template for Array2 class
|
// *********************************************** Template for Array2 class
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
// Created on: 2002-04-09
|
|
||||||
// Created by: Alexander KARTOMIN (akm)
|
|
||||||
// Copyright (c) 2002-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.
|
|
||||||
|
|
||||||
// Purpose: NCollection_BaseCollection is the base abstract class for
|
|
||||||
// all collection templates of this package.
|
|
||||||
// The set of collections is similar to that of TCollection.
|
|
||||||
// Also the methods of classes have mostly the same names for
|
|
||||||
// easy switch from TCollection <-> NCollection containers.
|
|
||||||
// NCollection is a nocdlpack, thus it is compiled without WOK.
|
|
||||||
// BaseCollection allows assigning the collections of different
|
|
||||||
// kinds (the items type being the same) with a few obvious
|
|
||||||
// exclusions - one can not assign any collection to the map
|
|
||||||
// having double data (two keys or a key plus value). Only the
|
|
||||||
// maps of the very same type may be assigned through operator=
|
|
||||||
// Said maps are: DoubleMap,
|
|
||||||
// DataMap,
|
|
||||||
// IndexedDataMap
|
|
||||||
// For the users needing control over the memory usage the
|
|
||||||
// allocators were added (see NCollection_BaseAllocator header)
|
|
||||||
// Others may forget it - BaseAllocator is used by default and
|
|
||||||
// then memory is managed through Standard::Allocate/::Free.
|
|
||||||
|
|
||||||
#ifndef NCollection_DefineBaseCollection_HeaderFile
|
|
||||||
#define NCollection_DefineBaseCollection_HeaderFile
|
|
||||||
|
|
||||||
#include <NCollection_BaseCollection.hxx>
|
|
||||||
|
|
||||||
// *************************************** Template for BaseCollection class
|
|
||||||
|
|
||||||
#define DEFINE_BASECOLLECTION(_ClassName_, TheItemType) \
|
|
||||||
typedef NCollection_BaseCollection<TheItemType > _ClassName_;
|
|
||||||
|
|
||||||
#endif
|
|
@ -29,7 +29,6 @@
|
|||||||
#ifndef NCollection_DefineDataMap_HeaderFile
|
#ifndef NCollection_DefineDataMap_HeaderFile
|
||||||
#define NCollection_DefineDataMap_HeaderFile
|
#define NCollection_DefineDataMap_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_DataMap.hxx>
|
#include <NCollection_DataMap.hxx>
|
||||||
|
|
||||||
// *********************************************** Class DataMap *************
|
// *********************************************** Class DataMap *************
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#ifndef NCollection_DefineDoubleMap_HeaderFile
|
#ifndef NCollection_DefineDoubleMap_HeaderFile
|
||||||
#define NCollection_DefineDoubleMap_HeaderFile
|
#define NCollection_DefineDoubleMap_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_DoubleMap.hxx>
|
#include <NCollection_DoubleMap.hxx>
|
||||||
|
|
||||||
// *********************************************** Class DoubleMap ************
|
// *********************************************** Class DoubleMap ************
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
class HClassName : public _Array1Type_, \
|
class HClassName : public _Array1Type_, \
|
||||||
public MMgt_TShared { \
|
public MMgt_TShared { \
|
||||||
public: \
|
public: \
|
||||||
|
DEFINE_STANDARD_ALLOC \
|
||||||
|
DEFINE_NCOLLECTION_ALLOC \
|
||||||
inline HClassName (const Standard_Integer theLower, \
|
inline HClassName (const Standard_Integer theLower, \
|
||||||
const Standard_Integer theUpper); \
|
const Standard_Integer theUpper); \
|
||||||
inline HClassName (const _Array1Type_&); \
|
inline HClassName (const _Array1Type_&); \
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
class HClassName : public _Array2Type_, \
|
class HClassName : public _Array2Type_, \
|
||||||
public MMgt_TShared { \
|
public MMgt_TShared { \
|
||||||
public: \
|
public: \
|
||||||
|
DEFINE_STANDARD_ALLOC \
|
||||||
|
DEFINE_NCOLLECTION_ALLOC \
|
||||||
inline HClassName (const Standard_Integer theRowLower, \
|
inline HClassName (const Standard_Integer theRowLower, \
|
||||||
const Standard_Integer theRowUpper, \
|
const Standard_Integer theRowUpper, \
|
||||||
const Standard_Integer theColLower, \
|
const Standard_Integer theColLower, \
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
class HClassName : public _SequenceType_, \
|
class HClassName : public _SequenceType_, \
|
||||||
public MMgt_TShared { \
|
public MMgt_TShared { \
|
||||||
public: \
|
public: \
|
||||||
|
DEFINE_STANDARD_ALLOC \
|
||||||
|
DEFINE_NCOLLECTION_ALLOC \
|
||||||
inline HClassName (); \
|
inline HClassName (); \
|
||||||
inline HClassName (const _SequenceType_&); \
|
inline HClassName (const _SequenceType_&); \
|
||||||
inline const _SequenceType_& Sequence () const; \
|
inline const _SequenceType_& Sequence () const; \
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#ifndef NCollection_DefineIndexedDataMap_HeaderFile
|
#ifndef NCollection_DefineIndexedDataMap_HeaderFile
|
||||||
#define NCollection_DefineIndexedDataMap_HeaderFile
|
#define NCollection_DefineIndexedDataMap_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_IndexedDataMap.hxx>
|
#include <NCollection_IndexedDataMap.hxx>
|
||||||
|
|
||||||
// *********************************************** Class IndexedDataMap ******
|
// *********************************************** Class IndexedDataMap ******
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#ifndef NCollection_DefineIndexedMap_HeaderFile
|
#ifndef NCollection_DefineIndexedMap_HeaderFile
|
||||||
#define NCollection_DefineIndexedMap_HeaderFile
|
#define NCollection_DefineIndexedMap_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_IndexedMap.hxx>
|
#include <NCollection_IndexedMap.hxx>
|
||||||
|
|
||||||
// *********************************************** Class IndexedMap ***********
|
// *********************************************** Class IndexedMap ***********
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
#ifndef NCollection_DefineMap_HeaderFile
|
#ifndef NCollection_DefineMap_HeaderFile
|
||||||
#define NCollection_DefineMap_HeaderFile
|
#define NCollection_DefineMap_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_Map.hxx>
|
#include <NCollection_Map.hxx>
|
||||||
|
|
||||||
// *********************************************** Class Map *****************
|
// *********************************************** Class Map *****************
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#ifndef NCollection_DefineSequence_HeaderFile
|
#ifndef NCollection_DefineSequence_HeaderFile
|
||||||
#define NCollection_DefineSequence_HeaderFile
|
#define NCollection_DefineSequence_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_Sequence.hxx>
|
#include <NCollection_Sequence.hxx>
|
||||||
|
|
||||||
// **************************************** Template for Sequence class ********
|
// **************************************** Template for Sequence class ********
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
// Created on: 2002-04-23
|
|
||||||
// Created by: Alexander KARTOMIN
|
|
||||||
// Copyright (c) 2002-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.
|
|
||||||
|
|
||||||
// Purpose: This Iterator class iterates on BaseList of TListNode and is
|
|
||||||
// instantiated in List/Set/Queue/Stack
|
|
||||||
// Remark: TListIterator is internal class
|
|
||||||
|
|
||||||
#ifndef NCollection_DefineTListIterator_HeaderFile
|
|
||||||
#define NCollection_DefineTListIterator_HeaderFile
|
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_TListIterator.hxx>
|
|
||||||
|
|
||||||
// ********************************** Implementation of the Iterator interface
|
|
||||||
#define DEFINE_TLISTITERATOR(_ClassName_, _BaseCollection_, TheItemType) \
|
|
||||||
typedef NCollection_TListIterator<TheItemType > _ClassName_;
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,28 +0,0 @@
|
|||||||
// Created on: 2002-04-23
|
|
||||||
// Created by: Alexander KARTOMIN (akm)
|
|
||||||
// Copyright (c) 2002-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.
|
|
||||||
|
|
||||||
// Purpose: Abstract list node class. Used by BaseList
|
|
||||||
// Remark: Internal class
|
|
||||||
|
|
||||||
#ifndef NCollection_DefineTListNode_HeaderFile
|
|
||||||
#define NCollection_DefineTListNode_HeaderFile
|
|
||||||
|
|
||||||
#include <NCollection_TListNode.hxx>
|
|
||||||
|
|
||||||
// ******************************* Class defining list node - for internal use
|
|
||||||
#define DEFINE_TLISTNODE(_ClassName_, _BaseCollection_, TheItemType) \
|
|
||||||
typedef NCollection_TListNode<TheItemType > _ClassName_;
|
|
||||||
|
|
||||||
#endif
|
|
@ -19,7 +19,6 @@
|
|||||||
#ifndef NCollection_DefineVector_HeaderFile
|
#ifndef NCollection_DefineVector_HeaderFile
|
||||||
#define NCollection_DefineVector_HeaderFile
|
#define NCollection_DefineVector_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_Vector.hxx>
|
#include <NCollection_Vector.hxx>
|
||||||
|
|
||||||
// Class NCollection_Vector (dynamic array of objects)
|
// Class NCollection_Vector (dynamic array of objects)
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#define NCollection_DoubleMap_HeaderFile
|
#define NCollection_DoubleMap_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_TypeDef.hxx>
|
#include <NCollection_TypeDef.hxx>
|
||||||
#include <NCollection_BaseCollection.hxx>
|
|
||||||
#include <NCollection_BaseMap.hxx>
|
#include <NCollection_BaseMap.hxx>
|
||||||
#include <NCollection_TListNode.hxx>
|
#include <NCollection_TListNode.hxx>
|
||||||
#include <Standard_TypeMismatch.hxx>
|
#include <Standard_TypeMismatch.hxx>
|
||||||
@ -38,9 +37,8 @@
|
|||||||
template < class TheKey1Type,
|
template < class TheKey1Type,
|
||||||
class TheKey2Type,
|
class TheKey2Type,
|
||||||
class Hasher1 = NCollection_DefaultHasher<TheKey1Type>,
|
class Hasher1 = NCollection_DefaultHasher<TheKey1Type>,
|
||||||
class Hasher2 = NCollection_DefaultHasher<TheKey2Type> > class NCollection_DoubleMap
|
class Hasher2 = NCollection_DefaultHasher<TheKey2Type> >
|
||||||
: public NCollection_BaseCollection<TheKey2Type>,
|
class NCollection_DoubleMap : public NCollection_BaseMap
|
||||||
public NCollection_BaseMap
|
|
||||||
{
|
{
|
||||||
// **************** Adaptation of the TListNode to the DOUBLEmap
|
// **************** Adaptation of the TListNode to the DOUBLEmap
|
||||||
public:
|
public:
|
||||||
@ -82,22 +80,19 @@ template < class TheKey1Type,
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// **************** Implementation of the Iterator interface.
|
// **************** Implementation of the Iterator interface.
|
||||||
class Iterator
|
class Iterator : public NCollection_BaseMap::Iterator
|
||||||
: public NCollection_BaseCollection<TheKey2Type>::Iterator,
|
|
||||||
public NCollection_BaseMap::Iterator
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Empty constructor
|
//! Empty constructor
|
||||||
Iterator (void) :
|
Iterator (void) {}
|
||||||
NCollection_BaseMap::Iterator() {}
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
Iterator (const NCollection_DoubleMap& theMap) :
|
Iterator (const NCollection_DoubleMap& theMap) :
|
||||||
NCollection_BaseMap::Iterator(theMap) {}
|
NCollection_BaseMap::Iterator(theMap) {}
|
||||||
//! Query if the end of collection is reached by iterator
|
//! Query if the end of collection is reached by iterator
|
||||||
virtual Standard_Boolean More(void) const
|
Standard_Boolean More(void) const
|
||||||
{ return PMore(); }
|
{ return PMore(); }
|
||||||
//! Make a step along the collection
|
//! Make a step along the collection
|
||||||
virtual void Next(void)
|
void Next(void)
|
||||||
{ PNext(); }
|
{ PNext(); }
|
||||||
//! Key1 inquiry
|
//! Key1 inquiry
|
||||||
const TheKey1Type& Key1(void) const
|
const TheKey1Type& Key1(void) const
|
||||||
@ -118,7 +113,7 @@ template < class TheKey1Type,
|
|||||||
return ((DoubleMapNode *) myNode)->Key2();
|
return ((DoubleMapNode *) myNode)->Key2();
|
||||||
}
|
}
|
||||||
//! Value access
|
//! Value access
|
||||||
virtual const TheKey2Type& Value(void) const
|
const TheKey2Type& Value(void) const
|
||||||
{
|
{
|
||||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||||
if (!More())
|
if (!More())
|
||||||
@ -127,7 +122,7 @@ template < class TheKey1Type,
|
|||||||
return ((DoubleMapNode *) myNode)->Value();
|
return ((DoubleMapNode *) myNode)->Value();
|
||||||
}
|
}
|
||||||
//! Value change access - denied
|
//! Value change access - denied
|
||||||
virtual TheKey2Type& ChangeValue(void) const
|
TheKey2Type& ChangeValue(void) const
|
||||||
{
|
{
|
||||||
Standard_ImmutableObject::Raise("NCollection_DoubleMap::Iterator::ChangeValue");
|
Standard_ImmutableObject::Raise("NCollection_DoubleMap::Iterator::ChangeValue");
|
||||||
return * (TheKey2Type *) NULL; // For compiler
|
return * (TheKey2Type *) NULL; // For compiler
|
||||||
@ -140,33 +135,22 @@ template < class TheKey1Type,
|
|||||||
//! Constructor
|
//! Constructor
|
||||||
NCollection_DoubleMap (const Standard_Integer NbBuckets=1,
|
NCollection_DoubleMap (const Standard_Integer NbBuckets=1,
|
||||||
const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
|
const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
|
||||||
: NCollection_BaseCollection<TheKey2Type>(theAllocator),
|
: NCollection_BaseMap (NbBuckets, Standard_False, theAllocator) {}
|
||||||
NCollection_BaseMap (NbBuckets, Standard_False) {}
|
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
NCollection_DoubleMap (const NCollection_DoubleMap& theOther)
|
NCollection_DoubleMap (const NCollection_DoubleMap& theOther)
|
||||||
: NCollection_BaseCollection<TheKey2Type>(theOther.myAllocator),
|
: NCollection_BaseMap (theOther.NbBuckets(), Standard_False, theOther.myAllocator)
|
||||||
NCollection_BaseMap (theOther.NbBuckets(), Standard_False)
|
|
||||||
{ *this = theOther; }
|
{ *this = theOther; }
|
||||||
|
|
||||||
//! Assign another collection
|
|
||||||
virtual void Assign(const NCollection_BaseCollection<TheKey2Type>& theOther)
|
|
||||||
{
|
|
||||||
if (this == &theOther)
|
|
||||||
return;
|
|
||||||
Standard_TypeMismatch::Raise ("NCollection_DoubleMap::Assign impossible");
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Exchange the content of two maps without re-allocations.
|
//! Exchange the content of two maps without re-allocations.
|
||||||
//! Notice that allocators will be swapped as well!
|
//! Notice that allocators will be swapped as well!
|
||||||
void Exchange (NCollection_DoubleMap& theOther)
|
void Exchange (NCollection_DoubleMap& theOther)
|
||||||
{
|
{
|
||||||
this->exchangeAllocators (theOther);
|
this->exchangeMapsData (theOther);
|
||||||
this->exchangeMapsData (theOther);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! = another map
|
//! Assignment
|
||||||
NCollection_DoubleMap& operator=(const NCollection_DoubleMap& theOther)
|
NCollection_DoubleMap& Assign (const NCollection_DoubleMap& theOther)
|
||||||
{
|
{
|
||||||
if (this == &theOther)
|
if (this == &theOther)
|
||||||
return *this;
|
return *this;
|
||||||
@ -190,13 +174,19 @@ template < class TheKey1Type,
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Assignment operator
|
||||||
|
NCollection_DoubleMap& operator= (const NCollection_DoubleMap& theOther)
|
||||||
|
{
|
||||||
|
return Assign (theOther);
|
||||||
|
}
|
||||||
|
|
||||||
//! ReSize
|
//! ReSize
|
||||||
void ReSize (const Standard_Integer N)
|
void ReSize (const Standard_Integer N)
|
||||||
{
|
{
|
||||||
NCollection_ListNode** ppNewData1 = NULL;
|
NCollection_ListNode** ppNewData1 = NULL;
|
||||||
NCollection_ListNode** ppNewData2 = NULL;
|
NCollection_ListNode** ppNewData2 = NULL;
|
||||||
Standard_Integer newBuck;
|
Standard_Integer newBuck;
|
||||||
if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator))
|
if (BeginResize (N, newBuck, ppNewData1, ppNewData2))
|
||||||
{
|
{
|
||||||
if (myData1)
|
if (myData1)
|
||||||
{
|
{
|
||||||
@ -221,7 +211,7 @@ template < class TheKey1Type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
|
EndResize (N, newBuck, ppNewData1, ppNewData2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +440,7 @@ template < class TheKey1Type,
|
|||||||
//! Clear data. If doReleaseMemory is false then the table of
|
//! Clear data. If doReleaseMemory is false then the table of
|
||||||
//! buckets is not released and will be reused.
|
//! buckets is not released and will be reused.
|
||||||
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
|
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
|
||||||
{ Destroy (DoubleMapNode::delNode, this->myAllocator, doReleaseMemory); }
|
{ Destroy (DoubleMapNode::delNode, doReleaseMemory); }
|
||||||
|
|
||||||
//! Clear data and reset allocator
|
//! Clear data and reset allocator
|
||||||
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
|
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
|
||||||
@ -465,17 +455,8 @@ template < class TheKey1Type,
|
|||||||
{ Clear(); }
|
{ Clear(); }
|
||||||
|
|
||||||
//! Size
|
//! Size
|
||||||
virtual Standard_Integer Size(void) const
|
Standard_Integer Size(void) const
|
||||||
{ return Extent(); }
|
{ return Extent(); }
|
||||||
|
|
||||||
private:
|
|
||||||
// ----------- PRIVATE METHODS -----------
|
|
||||||
|
|
||||||
//! Creates Iterator for use on BaseCollection
|
|
||||||
virtual TYPENAME NCollection_BaseCollection<TheKey2Type>::Iterator&
|
|
||||||
CreateIterator(void) const
|
|
||||||
{ return *(new (this->IterAllocator()) Iterator(*this)); }
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#ifndef NCollection_IndexedDataMap_HeaderFile
|
#ifndef NCollection_IndexedDataMap_HeaderFile
|
||||||
#define NCollection_IndexedDataMap_HeaderFile
|
#define NCollection_IndexedDataMap_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_BaseCollection.hxx>
|
|
||||||
#include <NCollection_BaseMap.hxx>
|
#include <NCollection_BaseMap.hxx>
|
||||||
#include <NCollection_TListNode.hxx>
|
#include <NCollection_TListNode.hxx>
|
||||||
#include <Standard_TypeMismatch.hxx>
|
#include <Standard_TypeMismatch.hxx>
|
||||||
@ -50,9 +49,7 @@
|
|||||||
template < class TheKeyType,
|
template < class TheKeyType,
|
||||||
class TheItemType,
|
class TheItemType,
|
||||||
class Hasher = NCollection_DefaultHasher<TheKeyType> >
|
class Hasher = NCollection_DefaultHasher<TheKeyType> >
|
||||||
class NCollection_IndexedDataMap
|
class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||||
: public NCollection_BaseCollection<TheItemType>,
|
|
||||||
public NCollection_BaseMap
|
|
||||||
{
|
{
|
||||||
//! Adaptation of the TListNode to the INDEXEDDatamap
|
//! Adaptation of the TListNode to the INDEXEDDatamap
|
||||||
private:
|
private:
|
||||||
@ -96,7 +93,7 @@ template < class TheKeyType,
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
//! Implementation of the Iterator interface.
|
//! Implementation of the Iterator interface.
|
||||||
class Iterator : public NCollection_BaseCollection<TheItemType>::Iterator
|
class Iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Empty constructor
|
//! Empty constructor
|
||||||
@ -109,15 +106,15 @@ template < class TheKeyType,
|
|||||||
myNode (myMap->nodeFromIndex (1)),
|
myNode (myMap->nodeFromIndex (1)),
|
||||||
myIndex (1) {}
|
myIndex (1) {}
|
||||||
//! Query if the end of collection is reached by iterator
|
//! Query if the end of collection is reached by iterator
|
||||||
virtual Standard_Boolean More(void) const
|
Standard_Boolean More(void) const
|
||||||
{ return (myMap != NULL) && (myIndex <= myMap->Extent()); }
|
{ return (myMap != NULL) && (myIndex <= myMap->Extent()); }
|
||||||
//! Make a step along the collection
|
//! Make a step along the collection
|
||||||
virtual void Next(void)
|
void Next(void)
|
||||||
{
|
{
|
||||||
myNode = myMap->nodeFromIndex (++myIndex);
|
myNode = myMap->nodeFromIndex (++myIndex);
|
||||||
}
|
}
|
||||||
//! Value access
|
//! Value access
|
||||||
virtual const TheItemType& Value(void) const
|
const TheItemType& Value(void) const
|
||||||
{
|
{
|
||||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||||
if (!More())
|
if (!More())
|
||||||
@ -126,7 +123,7 @@ template < class TheKeyType,
|
|||||||
return myNode->Value();
|
return myNode->Value();
|
||||||
}
|
}
|
||||||
//! ChangeValue access
|
//! ChangeValue access
|
||||||
virtual TheItemType& ChangeValue(void) const
|
TheItemType& ChangeValue(void) const
|
||||||
{
|
{
|
||||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||||
if (!More())
|
if (!More())
|
||||||
@ -144,7 +141,7 @@ template < class TheKeyType,
|
|||||||
return myNode->Key1();
|
return myNode->Key1();
|
||||||
}
|
}
|
||||||
//! Performs comparison of two iterators.
|
//! Performs comparison of two iterators.
|
||||||
virtual Standard_Boolean IsEqual (const Iterator& theOther) const
|
Standard_Boolean IsEqual (const Iterator& theOther) const
|
||||||
{
|
{
|
||||||
return myMap == theOther.myMap &&
|
return myMap == theOther.myMap &&
|
||||||
myNode == theOther.myNode &&
|
myNode == theOther.myNode &&
|
||||||
@ -180,34 +177,22 @@ template < class TheKeyType,
|
|||||||
//! Constructor
|
//! Constructor
|
||||||
NCollection_IndexedDataMap (const Standard_Integer NbBuckets=1,
|
NCollection_IndexedDataMap (const Standard_Integer NbBuckets=1,
|
||||||
const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
|
const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
|
||||||
: NCollection_BaseCollection<TheItemType>(theAllocator),
|
: NCollection_BaseMap (NbBuckets, Standard_False, theAllocator) {}
|
||||||
NCollection_BaseMap (NbBuckets, Standard_False) {}
|
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
NCollection_IndexedDataMap (const NCollection_IndexedDataMap& theOther)
|
NCollection_IndexedDataMap (const NCollection_IndexedDataMap& theOther)
|
||||||
: NCollection_BaseCollection<TheItemType>(theOther.myAllocator),
|
: NCollection_BaseMap (theOther.NbBuckets(), Standard_False, theOther.myAllocator)
|
||||||
NCollection_BaseMap (theOther.NbBuckets(), Standard_False)
|
|
||||||
{ *this = theOther; }
|
{ *this = theOther; }
|
||||||
|
|
||||||
//! Assign another collection
|
|
||||||
virtual void Assign(const NCollection_BaseCollection<TheItemType>& theOther)
|
|
||||||
{
|
|
||||||
if (this == &theOther)
|
|
||||||
return;
|
|
||||||
Standard_TypeMismatch::Raise("NCollection_IndexedDataMap::Assign");
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Exchange the content of two maps without re-allocations.
|
//! Exchange the content of two maps without re-allocations.
|
||||||
//! Notice that allocators will be swapped as well!
|
//! Notice that allocators will be swapped as well!
|
||||||
void Exchange (NCollection_IndexedDataMap& theOther)
|
void Exchange (NCollection_IndexedDataMap& theOther)
|
||||||
{
|
{
|
||||||
this->exchangeAllocators (theOther);
|
this->exchangeMapsData (theOther);
|
||||||
this->exchangeMapsData (theOther);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! = another map
|
//! Assignment
|
||||||
NCollection_IndexedDataMap& operator=
|
NCollection_IndexedDataMap& Assign (const NCollection_IndexedDataMap& theOther)
|
||||||
(const NCollection_IndexedDataMap& theOther)
|
|
||||||
{
|
{
|
||||||
if (this == &theOther)
|
if (this == &theOther)
|
||||||
return *this;
|
return *this;
|
||||||
@ -231,13 +216,19 @@ template < class TheKeyType,
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Assignment operator
|
||||||
|
NCollection_IndexedDataMap& operator= (const NCollection_IndexedDataMap& theOther)
|
||||||
|
{
|
||||||
|
return Assign (theOther);
|
||||||
|
}
|
||||||
|
|
||||||
//! ReSize
|
//! ReSize
|
||||||
void ReSize (const Standard_Integer N)
|
void ReSize (const Standard_Integer N)
|
||||||
{
|
{
|
||||||
NCollection_ListNode** ppNewData1 = NULL;
|
NCollection_ListNode** ppNewData1 = NULL;
|
||||||
NCollection_ListNode** ppNewData2 = NULL;
|
NCollection_ListNode** ppNewData2 = NULL;
|
||||||
Standard_Integer newBuck;
|
Standard_Integer newBuck;
|
||||||
if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator))
|
if (BeginResize (N, newBuck, ppNewData1, ppNewData2))
|
||||||
{
|
{
|
||||||
if (myData1)
|
if (myData1)
|
||||||
{
|
{
|
||||||
@ -262,7 +253,7 @@ template < class TheKeyType,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
|
EndResize (N, newBuck, ppNewData1, ppNewData2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +516,7 @@ template < class TheKeyType,
|
|||||||
//! Clear data. If doReleaseMemory is false then the table of
|
//! Clear data. If doReleaseMemory is false then the table of
|
||||||
//! buckets is not released and will be reused.
|
//! buckets is not released and will be reused.
|
||||||
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
|
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
|
||||||
{ Destroy (IndexedDataMapNode::delNode, this->myAllocator, doReleaseMemory); }
|
{ Destroy (IndexedDataMapNode::delNode, doReleaseMemory); }
|
||||||
|
|
||||||
//! Clear data and reset allocator
|
//! Clear data and reset allocator
|
||||||
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
|
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
|
||||||
@ -540,17 +531,12 @@ template < class TheKeyType,
|
|||||||
{ Clear(); }
|
{ Clear(); }
|
||||||
|
|
||||||
//! Size
|
//! Size
|
||||||
virtual Standard_Integer Size(void) const
|
Standard_Integer Size(void) const
|
||||||
{ return Extent(); }
|
{ return Extent(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// ----------- PRIVATE METHODS -----------
|
// ----------- PRIVATE METHODS -----------
|
||||||
|
|
||||||
//! Creates Iterator for use on BaseCollection
|
|
||||||
virtual TYPENAME NCollection_BaseCollection<TheItemType>::Iterator&
|
|
||||||
CreateIterator(void) const
|
|
||||||
{ return *(new (this->IterAllocator()) Iterator(*this)); }
|
|
||||||
|
|
||||||
//! Find map node associated with specified index.
|
//! Find map node associated with specified index.
|
||||||
//! Return NULL if not found (exception-free internal implementation).
|
//! Return NULL if not found (exception-free internal implementation).
|
||||||
IndexedDataMapNode* nodeFromIndex (const Standard_Integer theKey2) const
|
IndexedDataMapNode* nodeFromIndex (const Standard_Integer theKey2) const
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#ifndef NCollection_IndexedMap_HeaderFile
|
#ifndef NCollection_IndexedMap_HeaderFile
|
||||||
#define NCollection_IndexedMap_HeaderFile
|
#define NCollection_IndexedMap_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_BaseCollection.hxx>
|
|
||||||
#include <NCollection_BaseMap.hxx>
|
#include <NCollection_BaseMap.hxx>
|
||||||
#include <NCollection_TListNode.hxx>
|
#include <NCollection_TListNode.hxx>
|
||||||
#include <NCollection_StlIterator.hxx>
|
#include <NCollection_StlIterator.hxx>
|
||||||
@ -42,9 +41,7 @@
|
|||||||
|
|
||||||
template < class TheKeyType,
|
template < class TheKeyType,
|
||||||
class Hasher = NCollection_DefaultHasher<TheKeyType> >
|
class Hasher = NCollection_DefaultHasher<TheKeyType> >
|
||||||
class NCollection_IndexedMap
|
class NCollection_IndexedMap : public NCollection_BaseMap
|
||||||
: public NCollection_BaseCollection<TheKeyType>,
|
|
||||||
public NCollection_BaseMap
|
|
||||||
{
|
{
|
||||||
// **************** Adaptation of the TListNode to the INDEXEDmap
|
// **************** Adaptation of the TListNode to the INDEXEDmap
|
||||||
private:
|
private:
|
||||||
@ -87,7 +84,6 @@ template < class TheKeyType,
|
|||||||
public:
|
public:
|
||||||
// **************** Implementation of the Iterator interface.
|
// **************** Implementation of the Iterator interface.
|
||||||
class Iterator
|
class Iterator
|
||||||
: public NCollection_BaseCollection<TheKeyType>::Iterator
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Empty constructor
|
//! Empty constructor
|
||||||
@ -99,13 +95,13 @@ template < class TheKeyType,
|
|||||||
myMap((NCollection_IndexedMap *) &theMap),
|
myMap((NCollection_IndexedMap *) &theMap),
|
||||||
myIndex(1) {}
|
myIndex(1) {}
|
||||||
//! Query if the end of collection is reached by iterator
|
//! Query if the end of collection is reached by iterator
|
||||||
virtual Standard_Boolean More(void) const
|
Standard_Boolean More(void) const
|
||||||
{ return (myMap != NULL) && (myIndex <= myMap->Extent()); }
|
{ return (myMap != NULL) && (myIndex <= myMap->Extent()); }
|
||||||
//! Make a step along the collection
|
//! Make a step along the collection
|
||||||
virtual void Next(void)
|
void Next(void)
|
||||||
{ myIndex++; }
|
{ myIndex++; }
|
||||||
//! Value access
|
//! Value access
|
||||||
virtual const TheKeyType& Value(void) const
|
const TheKeyType& Value(void) const
|
||||||
{
|
{
|
||||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||||
if (!More())
|
if (!More())
|
||||||
@ -114,13 +110,13 @@ template < class TheKeyType,
|
|||||||
return myMap->FindKey(myIndex);
|
return myMap->FindKey(myIndex);
|
||||||
}
|
}
|
||||||
//! Value change access denied - use Substitute
|
//! Value change access denied - use Substitute
|
||||||
virtual TheKeyType& ChangeValue(void) const
|
TheKeyType& ChangeValue(void) const
|
||||||
{
|
{
|
||||||
Standard_ImmutableObject::Raise ("impossible to ChangeValue");
|
Standard_ImmutableObject::Raise ("impossible to ChangeValue");
|
||||||
return * (TheKeyType *) NULL; // This for compiler
|
return * (TheKeyType *) NULL; // This for compiler
|
||||||
}
|
}
|
||||||
//! Performs comparison of two iterators.
|
//! Performs comparison of two iterators.
|
||||||
virtual Standard_Boolean IsEqual (const Iterator& theOther) const
|
Standard_Boolean IsEqual (const Iterator& theOther) const
|
||||||
{
|
{
|
||||||
return myMap == theOther.myMap && myIndex == theOther.myIndex;
|
return myMap == theOther.myMap && myIndex == theOther.myIndex;
|
||||||
}
|
}
|
||||||
@ -144,39 +140,23 @@ template < class TheKeyType,
|
|||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
NCollection_IndexedMap (const Standard_Integer NbBuckets=1,
|
NCollection_IndexedMap (const Standard_Integer NbBuckets=1,
|
||||||
const Handle(NCollection_BaseAllocator)& theAllocator=0L) :
|
const Handle(NCollection_BaseAllocator)& theAllocator=0L)
|
||||||
NCollection_BaseCollection<TheKeyType>(theAllocator),
|
: NCollection_BaseMap (NbBuckets, Standard_False, theAllocator) {}
|
||||||
NCollection_BaseMap (NbBuckets, Standard_False) {}
|
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
NCollection_IndexedMap (const NCollection_IndexedMap& theOther) :
|
NCollection_IndexedMap (const NCollection_IndexedMap& theOther)
|
||||||
NCollection_BaseCollection<TheKeyType>(theOther.myAllocator),
|
: NCollection_BaseMap (theOther.NbBuckets(), Standard_False, theOther.myAllocator)
|
||||||
NCollection_BaseMap (theOther.NbBuckets(), Standard_False)
|
|
||||||
{ *this = theOther; }
|
{ *this = theOther; }
|
||||||
|
|
||||||
//! Assign another collection
|
|
||||||
virtual void Assign (const NCollection_BaseCollection<TheKeyType>& theOther)
|
|
||||||
{
|
|
||||||
if (this == &theOther)
|
|
||||||
return;
|
|
||||||
Clear();
|
|
||||||
ReSize (theOther.Size()-1);
|
|
||||||
TYPENAME NCollection_BaseCollection<TheKeyType>::Iterator& anIter =
|
|
||||||
theOther.CreateIterator();
|
|
||||||
for (; anIter.More(); anIter.Next())
|
|
||||||
Add(anIter.Value());
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Exchange the content of two maps without re-allocations.
|
//! Exchange the content of two maps without re-allocations.
|
||||||
//! Notice that allocators will be swapped as well!
|
//! Notice that allocators will be swapped as well!
|
||||||
void Exchange (NCollection_IndexedMap& theOther)
|
void Exchange (NCollection_IndexedMap& theOther)
|
||||||
{
|
{
|
||||||
this->exchangeAllocators (theOther);
|
this->exchangeMapsData (theOther);
|
||||||
this->exchangeMapsData (theOther);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! = another map
|
//! Assign
|
||||||
NCollection_IndexedMap& operator= (const NCollection_IndexedMap& theOther)
|
NCollection_IndexedMap& Assign (const NCollection_IndexedMap& theOther)
|
||||||
{
|
{
|
||||||
if (this == &theOther)
|
if (this == &theOther)
|
||||||
return *this;
|
return *this;
|
||||||
@ -199,13 +179,19 @@ template < class TheKeyType,
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Assignment operator
|
||||||
|
NCollection_IndexedMap& operator= (const NCollection_IndexedMap& theOther)
|
||||||
|
{
|
||||||
|
return Assign (theOther);
|
||||||
|
}
|
||||||
|
|
||||||
//! ReSize
|
//! ReSize
|
||||||
void ReSize (const Standard_Integer N)
|
void ReSize (const Standard_Integer N)
|
||||||
{
|
{
|
||||||
NCollection_ListNode** ppNewData1 = NULL;
|
NCollection_ListNode** ppNewData1 = NULL;
|
||||||
NCollection_ListNode** ppNewData2 = NULL;
|
NCollection_ListNode** ppNewData2 = NULL;
|
||||||
Standard_Integer newBuck;
|
Standard_Integer newBuck;
|
||||||
if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator))
|
if (BeginResize (N, newBuck, ppNewData1, ppNewData2))
|
||||||
{
|
{
|
||||||
if (myData1)
|
if (myData1)
|
||||||
{
|
{
|
||||||
@ -233,7 +219,7 @@ template < class TheKeyType,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
|
EndResize (N, newBuck, ppNewData1, ppNewData2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,7 +391,7 @@ template < class TheKeyType,
|
|||||||
//! Clear data. If doReleaseMemory is false then the table of
|
//! Clear data. If doReleaseMemory is false then the table of
|
||||||
//! buckets is not released and will be reused.
|
//! buckets is not released and will be reused.
|
||||||
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
|
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
|
||||||
{ Destroy (IndexedMapNode::delNode, this->myAllocator, doReleaseMemory); }
|
{ Destroy (IndexedMapNode::delNode, doReleaseMemory); }
|
||||||
|
|
||||||
//! Clear data and reset allocator
|
//! Clear data and reset allocator
|
||||||
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
|
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
|
||||||
@ -420,17 +406,8 @@ template < class TheKeyType,
|
|||||||
{ Clear(); }
|
{ Clear(); }
|
||||||
|
|
||||||
//! Size
|
//! Size
|
||||||
virtual Standard_Integer Size(void) const
|
Standard_Integer Size(void) const
|
||||||
{ return Extent(); }
|
{ return Extent(); }
|
||||||
|
|
||||||
private:
|
|
||||||
// ----------- PRIVATE METHODS -----------
|
|
||||||
|
|
||||||
//! Creates Iterator for use on BaseCollection
|
|
||||||
virtual TYPENAME NCollection_BaseCollection<TheKeyType>::Iterator&
|
|
||||||
CreateIterator(void) const
|
|
||||||
{ return *(new (this->IterAllocator()) Iterator(*this)); }
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,9 +28,8 @@
|
|||||||
* and the last one.
|
* and the last one.
|
||||||
* Inherits BaseList, adding the data item to each node.
|
* Inherits BaseList, adding the data item to each node.
|
||||||
*/
|
*/
|
||||||
template <class TheItemType> class NCollection_List
|
template <class TheItemType>
|
||||||
: public NCollection_BaseCollection<TheItemType>,
|
class NCollection_List : public NCollection_BaseList
|
||||||
public NCollection_BaseList
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! STL-compliant typedef for value type
|
//! STL-compliant typedef for value type
|
||||||
@ -63,57 +62,39 @@ public:
|
|||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
NCollection_List(const Handle(NCollection_BaseAllocator)& theAllocator=0L) :
|
NCollection_List(const Handle(NCollection_BaseAllocator)& theAllocator=0L) :
|
||||||
NCollection_BaseCollection<TheItemType>(theAllocator),
|
NCollection_BaseList(theAllocator) {}
|
||||||
NCollection_BaseList() {}
|
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
NCollection_List (const NCollection_List& theOther) :
|
NCollection_List (const NCollection_List& theOther) :
|
||||||
NCollection_BaseCollection<TheItemType>(theOther.myAllocator),
|
NCollection_BaseList(theOther.myAllocator)
|
||||||
NCollection_BaseList()
|
{
|
||||||
{ *this = theOther; }
|
Assign (theOther);
|
||||||
|
}
|
||||||
|
|
||||||
//! Size - Number of items
|
//! Size - Number of items
|
||||||
virtual Standard_Integer Size (void) const
|
Standard_Integer Size (void) const
|
||||||
{ return Extent(); }
|
{ return Extent(); }
|
||||||
|
|
||||||
//! Replace this list by the items of theOther collection
|
|
||||||
virtual void Assign (const NCollection_BaseCollection<TheItemType>& theOther)
|
|
||||||
{
|
|
||||||
if (this == &theOther)
|
|
||||||
return;
|
|
||||||
Clear();
|
|
||||||
TYPENAME NCollection_BaseCollection<TheItemType>::Iterator& anIter =
|
|
||||||
theOther.CreateIterator();
|
|
||||||
for (; anIter.More(); anIter.Next())
|
|
||||||
{
|
|
||||||
ListNode* pNew = new (this->myAllocator) ListNode(anIter.Value());
|
|
||||||
PAppend(pNew);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Replace this list by the items of another list (theOther parameter)
|
//! Replace this list by the items of another list (theOther parameter)
|
||||||
void Assign (const NCollection_List& theOther)
|
void Assign (const NCollection_List& theOther)
|
||||||
{
|
{
|
||||||
if (this != &theOther) {
|
if (this != &theOther) {
|
||||||
Clear();
|
Clear(theOther.myAllocator);
|
||||||
appendList(theOther.PFirst());
|
appendList(theOther.PFirst());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Replace this list by the items of theOther list
|
//! Replacement operator
|
||||||
NCollection_List& operator= (const NCollection_List& theOther)
|
NCollection_List& operator= (const NCollection_List& theOther)
|
||||||
{
|
{
|
||||||
if (this != &theOther) {
|
Assign (theOther);
|
||||||
Clear (theOther.myAllocator);
|
|
||||||
appendList(theOther.PFirst());
|
|
||||||
}
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Clear this list
|
//! Clear this list
|
||||||
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator=0L)
|
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator=0L)
|
||||||
{
|
{
|
||||||
PClear (ListNode::delNode, this->myAllocator);
|
PClear (ListNode::delNode);
|
||||||
if (!theAllocator.IsNull())
|
if (!theAllocator.IsNull())
|
||||||
this->myAllocator = theAllocator;
|
this->myAllocator = theAllocator;
|
||||||
}
|
}
|
||||||
@ -203,12 +184,12 @@ public:
|
|||||||
|
|
||||||
//! RemoveFirst item
|
//! RemoveFirst item
|
||||||
void RemoveFirst (void)
|
void RemoveFirst (void)
|
||||||
{ PRemoveFirst (ListNode::delNode, this->myAllocator); }
|
{ PRemoveFirst (ListNode::delNode); }
|
||||||
|
|
||||||
//! Remove item
|
//! Remove item
|
||||||
void Remove (Iterator& theIter)
|
void Remove (Iterator& theIter)
|
||||||
{
|
{
|
||||||
PRemove (theIter, ListNode::delNode, this->myAllocator);
|
PRemove (theIter, ListNode::delNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! InsertBefore
|
//! InsertBefore
|
||||||
@ -291,11 +272,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
// ----------- PRIVATE METHODS -----------
|
// ----------- PRIVATE METHODS -----------
|
||||||
|
|
||||||
//! Creates Iterator for use on BaseCollection
|
|
||||||
virtual TYPENAME NCollection_BaseCollection<TheItemType>::Iterator&
|
|
||||||
CreateIterator(void) const
|
|
||||||
{ return *(new (this->IterAllocator()) Iterator(*this)); }
|
|
||||||
|
|
||||||
//! append the list headed by the given ListNode
|
//! append the list headed by the given ListNode
|
||||||
void appendList(const NCollection_ListNode * pCur) {
|
void appendList(const NCollection_ListNode * pCur) {
|
||||||
while (pCur) {
|
while (pCur) {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#define NCollection_ListNode_HeaderFile
|
#define NCollection_ListNode_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
#include <NCollection_BaseAllocator.hxx>
|
||||||
|
#include <NCollection_DefineAlloc.hxx>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: This class is used to represent a node in the BaseList and
|
* Purpose: This class is used to represent a node in the BaseList and
|
||||||
@ -24,7 +25,10 @@
|
|||||||
*/
|
*/
|
||||||
class NCollection_ListNode
|
class NCollection_ListNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// define new operator for use with NCollection allocators
|
||||||
|
DEFINE_NCOLLECTION_ALLOC
|
||||||
|
public:
|
||||||
//! The only constructor
|
//! The only constructor
|
||||||
NCollection_ListNode (NCollection_ListNode* theNext)
|
NCollection_ListNode (NCollection_ListNode* theNext)
|
||||||
{ myNext = theNext; }
|
{ myNext = theNext; }
|
||||||
@ -39,10 +43,10 @@ class NCollection_ListNode
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
//! operator= - forbidden
|
//! operator= - forbidden
|
||||||
NCollection_ListNode& operator=(const NCollection_ListNode& )
|
NCollection_ListNode& operator= (const NCollection_ListNode&);
|
||||||
{return *this;}
|
|
||||||
//! copy constructor - forbidden
|
//! copy constructor - forbidden
|
||||||
NCollection_ListNode (const NCollection_ListNode& ) {}
|
NCollection_ListNode (const NCollection_ListNode&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NCollection_ListNode * myNext; //!< Pointer to the next node
|
NCollection_ListNode * myNext; //!< Pointer to the next node
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
NCollection_LocalArray ()
|
NCollection_LocalArray ()
|
||||||
: myPtr (myBuffer) {}
|
: myPtr (myBuffer) {}
|
||||||
|
|
||||||
virtual ~NCollection_LocalArray()
|
~NCollection_LocalArray()
|
||||||
{
|
{
|
||||||
Deallocate();
|
Deallocate();
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#ifndef NCollection_Map_HeaderFile
|
#ifndef NCollection_Map_HeaderFile
|
||||||
#define NCollection_Map_HeaderFile
|
#define NCollection_Map_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_BaseCollection.hxx>
|
|
||||||
#include <NCollection_BaseMap.hxx>
|
#include <NCollection_BaseMap.hxx>
|
||||||
#include <NCollection_DataMap.hxx>
|
#include <NCollection_DataMap.hxx>
|
||||||
#include <NCollection_TListNode.hxx>
|
#include <NCollection_TListNode.hxx>
|
||||||
@ -58,9 +57,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
template < class TheKeyType,
|
template < class TheKeyType,
|
||||||
class Hasher = NCollection_DefaultHasher<TheKeyType> > class NCollection_Map
|
class Hasher = NCollection_DefaultHasher<TheKeyType> >
|
||||||
: public NCollection_BaseCollection<TheKeyType>,
|
class NCollection_Map : public NCollection_BaseMap
|
||||||
public NCollection_BaseMap
|
|
||||||
{
|
{
|
||||||
//! Adaptation of the TListNode to the map notations
|
//! Adaptation of the TListNode to the map notations
|
||||||
public:
|
public:
|
||||||
@ -80,9 +78,7 @@ template < class TheKeyType,
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
//! Implementation of the Iterator interface.
|
//! Implementation of the Iterator interface.
|
||||||
class Iterator
|
class Iterator : public NCollection_BaseMap::Iterator
|
||||||
: public NCollection_BaseCollection<TheKeyType>::Iterator,
|
|
||||||
public NCollection_BaseMap::Iterator
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Empty constructor
|
//! Empty constructor
|
||||||
@ -92,13 +88,13 @@ template < class TheKeyType,
|
|||||||
Iterator (const NCollection_Map& theMap) :
|
Iterator (const NCollection_Map& theMap) :
|
||||||
NCollection_BaseMap::Iterator(theMap) {}
|
NCollection_BaseMap::Iterator(theMap) {}
|
||||||
//! Query if the end of collection is reached by iterator
|
//! Query if the end of collection is reached by iterator
|
||||||
virtual Standard_Boolean More(void) const
|
Standard_Boolean More(void) const
|
||||||
{ return PMore(); }
|
{ return PMore(); }
|
||||||
//! Make a step along the collection
|
//! Make a step along the collection
|
||||||
virtual void Next(void)
|
void Next(void)
|
||||||
{ PNext(); }
|
{ PNext(); }
|
||||||
//! Value inquiry
|
//! Value inquiry
|
||||||
virtual const TheKeyType& Value(void) const
|
const TheKeyType& Value(void) const
|
||||||
{
|
{
|
||||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||||
if (!More())
|
if (!More())
|
||||||
@ -107,7 +103,7 @@ template < class TheKeyType,
|
|||||||
return ((MapNode *) myNode)->Value();
|
return ((MapNode *) myNode)->Value();
|
||||||
}
|
}
|
||||||
//! Value change access - denied
|
//! Value change access - denied
|
||||||
virtual TheKeyType& ChangeValue(void) const
|
TheKeyType& ChangeValue(void) const
|
||||||
{
|
{
|
||||||
Standard_ImmutableObject::Raise("NCollection_Map::Iterator::ChangeValue");
|
Standard_ImmutableObject::Raise("NCollection_Map::Iterator::ChangeValue");
|
||||||
return * (TheKeyType *) NULL; // For compiler
|
return * (TheKeyType *) NULL; // For compiler
|
||||||
@ -137,40 +133,23 @@ template < class TheKeyType,
|
|||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
NCollection_Map (const Standard_Integer NbBuckets = 1,
|
NCollection_Map (const Standard_Integer NbBuckets = 1,
|
||||||
const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
|
const Handle(NCollection_BaseAllocator)& theAllocator = 0L) :
|
||||||
: NCollection_BaseCollection<TheKeyType>(theAllocator),
|
NCollection_BaseMap (NbBuckets, Standard_True, theAllocator) {}
|
||||||
NCollection_BaseMap (NbBuckets, Standard_True) {}
|
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
NCollection_Map (const NCollection_Map& theOther)
|
NCollection_Map (const NCollection_Map& theOther) :
|
||||||
: NCollection_BaseCollection<TheKeyType>(theOther.myAllocator),
|
NCollection_BaseMap (theOther.NbBuckets(), Standard_True, theOther.myAllocator)
|
||||||
NCollection_BaseMap (theOther.NbBuckets(), Standard_True)
|
|
||||||
{ *this = theOther; }
|
{ *this = theOther; }
|
||||||
|
|
||||||
//! Assign another collection
|
|
||||||
virtual void Assign (const NCollection_BaseCollection<TheKeyType>& theOther)
|
|
||||||
{
|
|
||||||
if (this == &theOther)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Clear();
|
|
||||||
ReSize (theOther.Size()-1);
|
|
||||||
TYPENAME NCollection_BaseCollection<TheKeyType>::Iterator& anIter =
|
|
||||||
theOther.CreateIterator();
|
|
||||||
for (; anIter.More(); anIter.Next())
|
|
||||||
Add (anIter.Value());
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Exchange the content of two maps without re-allocations.
|
//! Exchange the content of two maps without re-allocations.
|
||||||
//! Notice that allocators will be swapped as well!
|
//! Notice that allocators will be swapped as well!
|
||||||
void Exchange (NCollection_Map& theOther)
|
void Exchange (NCollection_Map& theOther)
|
||||||
{
|
{
|
||||||
this->exchangeAllocators (theOther);
|
this->exchangeMapsData (theOther);
|
||||||
this->exchangeMapsData (theOther);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! = another map
|
//! Assign
|
||||||
NCollection_Map& operator= (const NCollection_Map& theOther)
|
NCollection_Map& Assign (const NCollection_Map& theOther)
|
||||||
{
|
{
|
||||||
if (this == &theOther)
|
if (this == &theOther)
|
||||||
return *this;
|
return *this;
|
||||||
@ -183,13 +162,19 @@ template < class TheKeyType,
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Assign operator
|
||||||
|
NCollection_Map& operator= (const NCollection_Map& theOther)
|
||||||
|
{
|
||||||
|
return Assign(theOther);
|
||||||
|
}
|
||||||
|
|
||||||
//! ReSize
|
//! ReSize
|
||||||
void ReSize (const Standard_Integer N)
|
void ReSize (const Standard_Integer N)
|
||||||
{
|
{
|
||||||
NCollection_ListNode** newdata = 0L;
|
NCollection_ListNode** newdata = 0L;
|
||||||
NCollection_ListNode** dummy = 0L;
|
NCollection_ListNode** dummy = 0L;
|
||||||
Standard_Integer newBuck;
|
Standard_Integer newBuck;
|
||||||
if (BeginResize (N, newBuck, newdata, dummy, this->myAllocator))
|
if (BeginResize (N, newBuck, newdata, dummy))
|
||||||
{
|
{
|
||||||
if (myData1)
|
if (myData1)
|
||||||
{
|
{
|
||||||
@ -212,7 +197,7 @@ template < class TheKeyType,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndResize (N, newBuck, newdata, dummy, this->myAllocator);
|
EndResize (N, newBuck, newdata, dummy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +287,7 @@ template < class TheKeyType,
|
|||||||
//! Clear data. If doReleaseMemory is false then the table of
|
//! Clear data. If doReleaseMemory is false then the table of
|
||||||
//! buckets is not released and will be reused.
|
//! buckets is not released and will be reused.
|
||||||
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
|
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
|
||||||
{ Destroy (MapNode::delNode, this->myAllocator, doReleaseMemory); }
|
{ Destroy (MapNode::delNode, doReleaseMemory); }
|
||||||
|
|
||||||
//! Clear data and reset allocator
|
//! Clear data and reset allocator
|
||||||
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
|
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
|
||||||
@ -317,7 +302,7 @@ template < class TheKeyType,
|
|||||||
{ Clear(); }
|
{ Clear(); }
|
||||||
|
|
||||||
//! Size
|
//! Size
|
||||||
virtual Standard_Integer Size(void) const
|
Standard_Integer Size(void) const
|
||||||
{ return Extent(); }
|
{ return Extent(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -589,15 +574,6 @@ template < class TheKeyType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//!@}
|
//!@}
|
||||||
|
|
||||||
private:
|
|
||||||
// ----------- PRIVATE METHODS -----------
|
|
||||||
|
|
||||||
//! Creates Iterator for use on BaseCollection
|
|
||||||
virtual TYPENAME NCollection_BaseCollection<TheKeyType>::Iterator&
|
|
||||||
CreateIterator(void) const
|
|
||||||
{ return *(new (this->IterAllocator()) Iterator(*this)); }
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#ifndef NCollection_Sequence_HeaderFile
|
#ifndef NCollection_Sequence_HeaderFile
|
||||||
#define NCollection_Sequence_HeaderFile
|
#define NCollection_Sequence_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_BaseCollection.hxx>
|
|
||||||
#include <NCollection_BaseSequence.hxx>
|
#include <NCollection_BaseSequence.hxx>
|
||||||
#include <NCollection_StlIterator.hxx>
|
#include <NCollection_StlIterator.hxx>
|
||||||
|
|
||||||
@ -29,9 +28,8 @@
|
|||||||
* Purpose: Definition of a sequence of elements indexed by
|
* Purpose: Definition of a sequence of elements indexed by
|
||||||
* an Integer in range of 1..n
|
* an Integer in range of 1..n
|
||||||
*/
|
*/
|
||||||
template <class TheItemType> class NCollection_Sequence
|
template <class TheItemType>
|
||||||
: public NCollection_BaseCollection<TheItemType>,
|
class NCollection_Sequence : public NCollection_BaseSequence
|
||||||
public NCollection_BaseSequence
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! STL-compliant typedef for value type
|
//! STL-compliant typedef for value type
|
||||||
@ -50,9 +48,6 @@ public:
|
|||||||
const TheItemType& Value () const { return myValue; }
|
const TheItemType& Value () const { return myValue; }
|
||||||
//! Variable value access
|
//! Variable value access
|
||||||
TheItemType& ChangeValue () { return myValue; }
|
TheItemType& ChangeValue () { return myValue; }
|
||||||
//! Memory allocation
|
|
||||||
DEFINE_STANDARD_ALLOC
|
|
||||||
DEFINE_NCOLLECTION_ALLOC
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TheItemType myValue;
|
TheItemType myValue;
|
||||||
@ -60,8 +55,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
//! Implementation of the Iterator interface.
|
//! Implementation of the Iterator interface.
|
||||||
class Iterator : public NCollection_BaseCollection<TheItemType>::Iterator,
|
class Iterator : public NCollection_BaseSequence::Iterator
|
||||||
public NCollection_BaseSequence::Iterator
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Empty constructor - for later Init
|
//! Empty constructor - for later Init
|
||||||
@ -70,18 +64,11 @@ public:
|
|||||||
Iterator (const NCollection_Sequence& theSeq,
|
Iterator (const NCollection_Sequence& theSeq,
|
||||||
const Standard_Boolean isStart = Standard_True)
|
const Standard_Boolean isStart = Standard_True)
|
||||||
: NCollection_BaseSequence::Iterator (theSeq, isStart) {}
|
: NCollection_BaseSequence::Iterator (theSeq, isStart) {}
|
||||||
//! Assignment
|
|
||||||
Iterator& operator= (const Iterator& theIt)
|
|
||||||
{
|
|
||||||
NCollection_BaseSequence::Iterator& me = * this;
|
|
||||||
me.operator= (theIt);
|
|
||||||
return * this;
|
|
||||||
}
|
|
||||||
//! Check end
|
//! Check end
|
||||||
virtual Standard_Boolean More (void) const
|
Standard_Boolean More (void) const
|
||||||
{ return (myCurrent!=NULL); }
|
{ return (myCurrent!=NULL); }
|
||||||
//! Make step
|
//! Make step
|
||||||
virtual void Next (void)
|
void Next (void)
|
||||||
{
|
{
|
||||||
if (myCurrent)
|
if (myCurrent)
|
||||||
{
|
{
|
||||||
@ -90,13 +77,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//! Constant value access
|
//! Constant value access
|
||||||
virtual const TheItemType& Value (void) const
|
const TheItemType& Value (void) const
|
||||||
{ return ((const Node *)myCurrent)->Value(); }
|
{ return ((const Node *)myCurrent)->Value(); }
|
||||||
//! Variable value access
|
//! Variable value access
|
||||||
virtual TheItemType& ChangeValue (void) const
|
TheItemType& ChangeValue (void) const
|
||||||
{ return ((Node *)myCurrent)->ChangeValue(); }
|
{ return ((Node *)myCurrent)->ChangeValue(); }
|
||||||
//! Performs comparison of two iterators.
|
//! Performs comparison of two iterators.
|
||||||
virtual Standard_Boolean IsEqual (const Iterator& theOther) const
|
Standard_Boolean IsEqual (const Iterator& theOther) const
|
||||||
{
|
{
|
||||||
return myCurrent == theOther.myCurrent;
|
return myCurrent == theOther.myCurrent;
|
||||||
}
|
}
|
||||||
@ -124,18 +111,18 @@ public:
|
|||||||
// ---------- PUBLIC METHODS ------------
|
// ---------- PUBLIC METHODS ------------
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
NCollection_Sequence(const Handle(NCollection_BaseAllocator)& theAllocator=0L)
|
NCollection_Sequence(const Handle(NCollection_BaseAllocator)& theAllocator=0L) :
|
||||||
: NCollection_BaseCollection<TheItemType>(theAllocator),
|
NCollection_BaseSequence(theAllocator) {}
|
||||||
NCollection_BaseSequence() {}
|
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
NCollection_Sequence (const NCollection_Sequence& theOther) :
|
NCollection_Sequence (const NCollection_Sequence& theOther) :
|
||||||
NCollection_BaseCollection<TheItemType>(theOther.myAllocator),
|
NCollection_BaseSequence(theOther.myAllocator)
|
||||||
NCollection_BaseSequence()
|
{
|
||||||
{ *this = theOther; }
|
Assign (theOther);
|
||||||
|
}
|
||||||
|
|
||||||
//! Number of items
|
//! Number of items
|
||||||
virtual Standard_Integer Size (void) const
|
Standard_Integer Size (void) const
|
||||||
{ return mySize; }
|
{ return mySize; }
|
||||||
|
|
||||||
//! Number of items
|
//! Number of items
|
||||||
@ -180,13 +167,13 @@ public:
|
|||||||
//! Clear the items out, take a new allocator if non null
|
//! Clear the items out, take a new allocator if non null
|
||||||
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator=0L)
|
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator=0L)
|
||||||
{
|
{
|
||||||
ClearSeq (delNode, this->myAllocator);
|
ClearSeq (delNode);
|
||||||
if (!theAllocator.IsNull())
|
if (!theAllocator.IsNull())
|
||||||
this->myAllocator = theAllocator;
|
this->myAllocator = theAllocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Replace this sequence by the items of theOther
|
//! Replace this sequence by the items of theOther
|
||||||
NCollection_Sequence& operator= (const NCollection_Sequence& theOther)
|
NCollection_Sequence& Assign (const NCollection_Sequence& theOther)
|
||||||
{
|
{
|
||||||
if (this == &theOther)
|
if (this == &theOther)
|
||||||
return *this;
|
return *this;
|
||||||
@ -200,30 +187,24 @@ public:
|
|||||||
return * this;
|
return * this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Replace this sequence by the items of theOther collection
|
//! Replacement operator
|
||||||
virtual void Assign (const NCollection_BaseCollection<TheItemType>& theOther)
|
NCollection_Sequence& operator= (const NCollection_Sequence& theOther)
|
||||||
{
|
{
|
||||||
if (this == &theOther)
|
return Assign (theOther);
|
||||||
return;
|
|
||||||
Clear ();
|
|
||||||
TYPENAME NCollection_BaseCollection<TheItemType>::Iterator& anIter =
|
|
||||||
theOther.CreateIterator();
|
|
||||||
for (; anIter.More(); anIter.Next())
|
|
||||||
Append(anIter.Value());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Remove one item
|
//! Remove one item
|
||||||
void Remove (Iterator& thePosition)
|
void Remove (Iterator& thePosition)
|
||||||
{ RemoveSeq (thePosition, delNode, this->myAllocator); }
|
{ RemoveSeq (thePosition, delNode); }
|
||||||
|
|
||||||
//! Remove one item
|
//! Remove one item
|
||||||
void Remove (const Standard_Integer theIndex)
|
void Remove (const Standard_Integer theIndex)
|
||||||
{ RemoveSeq (theIndex, delNode, this->myAllocator); }
|
{ RemoveSeq (theIndex, delNode); }
|
||||||
|
|
||||||
//! Remove range of items
|
//! Remove range of items
|
||||||
void Remove (const Standard_Integer theFromIndex,
|
void Remove (const Standard_Integer theFromIndex,
|
||||||
const Standard_Integer theToIndex)
|
const Standard_Integer theToIndex)
|
||||||
{ RemoveSeq (theFromIndex, theToIndex, delNode, this->myAllocator); }
|
{ RemoveSeq (theFromIndex, theToIndex, delNode); }
|
||||||
|
|
||||||
//! Append one item
|
//! Append one item
|
||||||
void Append (const TheItemType& theItem)
|
void Append (const TheItemType& theItem)
|
||||||
@ -367,14 +348,7 @@ public:
|
|||||||
~NCollection_Sequence (void)
|
~NCollection_Sequence (void)
|
||||||
{ Clear(); }
|
{ Clear(); }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// ----------- PRIVATE METHODS -----------
|
|
||||||
|
|
||||||
//! Creates Iterator for use on BaseCollection
|
|
||||||
virtual TYPENAME NCollection_BaseCollection<TheItemType>::Iterator&
|
|
||||||
CreateIterator(void) const
|
|
||||||
{ return *(new (this->IterAllocator()) Iterator(*this)); }
|
|
||||||
|
|
||||||
// ---------- FRIEND CLASSES ------------
|
// ---------- FRIEND CLASSES ------------
|
||||||
friend class Iterator;
|
friend class Iterator;
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
// Created on: 2003-05-04
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
// DEFINITION OF BASE COLLECTIONS FOR Open Cascade STANDARD TYPES
|
|
||||||
|
|
||||||
#ifndef _NCollection_StdBase_HeaderFile
|
|
||||||
#define _NCollection_StdBase_HeaderFile
|
|
||||||
|
|
||||||
#include <Standard_PrimitiveTypes.hxx>
|
|
||||||
#include <TCollection_AsciiString.hxx>
|
|
||||||
#include <TCollection_ExtendedString.hxx>
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
|
|
||||||
DEFINE_BASECOLLECTION(NCollection_BaseCollInteger , Standard_Integer)
|
|
||||||
DEFINE_BASECOLLECTION(NCollection_BaseCollReal , Standard_Real)
|
|
||||||
DEFINE_BASECOLLECTION(NCollection_BaseCollCharacter , Standard_Character)
|
|
||||||
DEFINE_BASECOLLECTION(NCollection_BaseCollBoolean , Standard_Boolean)
|
|
||||||
DEFINE_BASECOLLECTION(NCollection_BaseCollAsciiString ,
|
|
||||||
TCollection_AsciiString)
|
|
||||||
DEFINE_BASECOLLECTION(NCollection_BaseCollExtendedString,
|
|
||||||
TCollection_ExtendedString)
|
|
||||||
DEFINE_BASECOLLECTION(NCollection_BaseCollTransient ,
|
|
||||||
Handle(Standard_Transient))
|
|
||||||
|
|
||||||
#endif
|
|
@ -68,7 +68,7 @@ namespace opencascade
|
|||||||
//! iterator requires Offset and Differ methods. See NCollection_Vector as
|
//! iterator requires Offset and Differ methods. See NCollection_Vector as
|
||||||
//! example of declaring custom STL iterators.
|
//! example of declaring custom STL iterators.
|
||||||
template<class Category, class BaseIterator, class ItemType, bool IsConstant>
|
template<class Category, class BaseIterator, class ItemType, bool IsConstant>
|
||||||
class NCollection_StlIterator : private BaseIterator,
|
class NCollection_StlIterator :
|
||||||
public std::iterator<Category, ItemType, ptrdiff_t,
|
public std::iterator<Category, ItemType, ptrdiff_t,
|
||||||
typename opencascade::conditional<IsConstant, const ItemType*, ItemType*>::type,
|
typename opencascade::conditional<IsConstant, const ItemType*, ItemType*>::type,
|
||||||
typename opencascade::conditional<IsConstant, const ItemType&, ItemType&>::type>
|
typename opencascade::conditional<IsConstant, const ItemType&, ItemType&>::type>
|
||||||
@ -80,22 +80,26 @@ public:
|
|||||||
|
|
||||||
//! Constructor from NCollection iterator
|
//! Constructor from NCollection iterator
|
||||||
NCollection_StlIterator (const BaseIterator& theIterator)
|
NCollection_StlIterator (const BaseIterator& theIterator)
|
||||||
: BaseIterator (theIterator)
|
: myIterator (theIterator)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//! Cast from non-const variant to const one
|
//! Cast from non-const variant to const one
|
||||||
NCollection_StlIterator (const NCollection_StlIterator<Category, BaseIterator, ItemType, false>& theIterator)
|
NCollection_StlIterator (const NCollection_StlIterator<Category, BaseIterator, ItemType, false>& theIterator)
|
||||||
: BaseIterator (theIterator)
|
: myIterator (theIterator.Iterator())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//! Assignment of non-const iterator to const one
|
//! Assignment of non-const iterator to const one
|
||||||
NCollection_StlIterator& operator= (const NCollection_StlIterator<Category, BaseIterator, ItemType, false>& theIterator)
|
NCollection_StlIterator& operator= (const NCollection_StlIterator<Category, BaseIterator, ItemType, false>& theIterator)
|
||||||
{
|
{
|
||||||
BaseIterator::operator= (theIterator);
|
myIterator = theIterator.myIterator;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend class NCollection_StlIterator<Category, BaseIterator, ItemType, !IsConstant>;
|
//! Access to NCollection iterator instance
|
||||||
|
const BaseIterator& Iterator () const
|
||||||
|
{
|
||||||
|
return myIterator;
|
||||||
|
}
|
||||||
|
|
||||||
protected: //! @name methods related to forward STL iterator
|
protected: //! @name methods related to forward STL iterator
|
||||||
|
|
||||||
@ -105,13 +109,13 @@ protected: //! @name methods related to forward STL iterator
|
|||||||
template<bool Condition>
|
template<bool Condition>
|
||||||
typename opencascade::enable_if<!Condition, ItemType&>::type Reference()
|
typename opencascade::enable_if<!Condition, ItemType&>::type Reference()
|
||||||
{
|
{
|
||||||
return BaseIterator::ChangeValue();
|
return myIterator.ChangeValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool Condition>
|
template<bool Condition>
|
||||||
typename opencascade::enable_if<Condition, const ItemType&>::type Reference()
|
typename opencascade::enable_if<Condition, const ItemType&>::type Reference()
|
||||||
{
|
{
|
||||||
return BaseIterator::Value();
|
return myIterator.Value();
|
||||||
}
|
}
|
||||||
|
|
||||||
public: //! @name methods related to forward STL iterator
|
public: //! @name methods related to forward STL iterator
|
||||||
@ -119,8 +123,8 @@ public: //! @name methods related to forward STL iterator
|
|||||||
//! Test for equality
|
//! Test for equality
|
||||||
bool operator== (const NCollection_StlIterator& theOther) const
|
bool operator== (const NCollection_StlIterator& theOther) const
|
||||||
{
|
{
|
||||||
return BaseIterator::More() == theOther.More() &&
|
return myIterator.More() == theOther.myIterator.More() &&
|
||||||
(!BaseIterator::More() || BaseIterator::IsEqual (theOther));
|
(!myIterator.More() || myIterator.IsEqual (theOther.myIterator));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Test for inequality
|
//! Test for inequality
|
||||||
@ -144,7 +148,7 @@ public: //! @name methods related to forward STL iterator
|
|||||||
//! Prefix increment
|
//! Prefix increment
|
||||||
NCollection_StlIterator& operator++()
|
NCollection_StlIterator& operator++()
|
||||||
{
|
{
|
||||||
BaseIterator::Next();
|
myIterator.Next();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +167,7 @@ public: //! @name methods related to bidirectional STL iterator
|
|||||||
{
|
{
|
||||||
Standard_STATIC_ASSERT((opencascade::is_same<std::bidirectional_iterator_tag,Category>::value ||
|
Standard_STATIC_ASSERT((opencascade::is_same<std::bidirectional_iterator_tag,Category>::value ||
|
||||||
opencascade::is_same<std::random_access_iterator_tag,Category>::value));
|
opencascade::is_same<std::random_access_iterator_tag,Category>::value));
|
||||||
BaseIterator::Previous();
|
myIterator.Previous();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +185,7 @@ public: //! @name methods related to random access STL iterator
|
|||||||
NCollection_StlIterator& operator+= (typename NCollection_StlIterator::difference_type theOffset)
|
NCollection_StlIterator& operator+= (typename NCollection_StlIterator::difference_type theOffset)
|
||||||
{
|
{
|
||||||
Standard_STATIC_ASSERT((opencascade::is_same<std::random_access_iterator_tag,Category>::value));
|
Standard_STATIC_ASSERT((opencascade::is_same<std::random_access_iterator_tag,Category>::value));
|
||||||
BaseIterator::Offset (theOffset);
|
myIterator.Offset (theOffset);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +213,7 @@ public: //! @name methods related to random access STL iterator
|
|||||||
typename NCollection_StlIterator::difference_type operator- (const NCollection_StlIterator& theOther) const
|
typename NCollection_StlIterator::difference_type operator- (const NCollection_StlIterator& theOther) const
|
||||||
{
|
{
|
||||||
Standard_STATIC_ASSERT((opencascade::is_same<std::random_access_iterator_tag,Category>::value));
|
Standard_STATIC_ASSERT((opencascade::is_same<std::random_access_iterator_tag,Category>::value));
|
||||||
return BaseIterator::Differ (theOther);
|
return myIterator.Differ (theOther.myIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Get item at offset from current
|
//! Get item at offset from current
|
||||||
@ -241,6 +245,10 @@ public: //! @name methods related to random access STL iterator
|
|||||||
{
|
{
|
||||||
return !(*this < theOther);
|
return !(*this < theOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! NCollection iterator
|
||||||
|
BaseIterator myIterator;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NCollection_StlIterator_HeaderFile
|
#endif // NCollection_StlIterator_HeaderFile
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#ifndef NCollection_TListIterator_HeaderFile
|
#ifndef NCollection_TListIterator_HeaderFile
|
||||||
#define NCollection_TListIterator_HeaderFile
|
#define NCollection_TListIterator_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_BaseCollection.hxx>
|
|
||||||
#include <NCollection_BaseList.hxx>
|
#include <NCollection_BaseList.hxx>
|
||||||
#include <NCollection_TListNode.hxx>
|
#include <NCollection_TListNode.hxx>
|
||||||
|
|
||||||
@ -26,8 +25,7 @@
|
|||||||
* Remark: TListIterator is internal class
|
* Remark: TListIterator is internal class
|
||||||
*/
|
*/
|
||||||
template <class TheItemType> class NCollection_TListIterator
|
template <class TheItemType> class NCollection_TListIterator
|
||||||
: public NCollection_BaseCollection<TheItemType>::Iterator,
|
: public NCollection_BaseList::Iterator
|
||||||
public NCollection_BaseList::Iterator
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Empty constructor - for later Init
|
//! Empty constructor - for later Init
|
||||||
@ -36,27 +34,20 @@ template <class TheItemType> class NCollection_TListIterator
|
|||||||
//! Constructor with initialisation
|
//! Constructor with initialisation
|
||||||
NCollection_TListIterator (const NCollection_BaseList& theList) :
|
NCollection_TListIterator (const NCollection_BaseList& theList) :
|
||||||
NCollection_BaseList::Iterator (theList) {}
|
NCollection_BaseList::Iterator (theList) {}
|
||||||
//! Assignment
|
|
||||||
NCollection_TListIterator& operator= (const NCollection_TListIterator& theIt)
|
|
||||||
{
|
|
||||||
NCollection_BaseList::Iterator& me = * this;
|
|
||||||
me.operator= (theIt);
|
|
||||||
return * this;
|
|
||||||
}
|
|
||||||
//! Check end
|
//! Check end
|
||||||
virtual Standard_Boolean More (void) const
|
Standard_Boolean More (void) const
|
||||||
{ return (myCurrent!=NULL); }
|
{ return (myCurrent!=NULL); }
|
||||||
//! Make step
|
//! Make step
|
||||||
virtual void Next (void)
|
void Next (void)
|
||||||
{
|
{
|
||||||
myPrevious = myCurrent;
|
myPrevious = myCurrent;
|
||||||
myCurrent = myCurrent->Next();
|
myCurrent = myCurrent->Next();
|
||||||
}
|
}
|
||||||
//! Constant Value access
|
//! Constant Value access
|
||||||
virtual const TheItemType& Value (void) const
|
const TheItemType& Value (void) const
|
||||||
{ return ((const NCollection_TListNode<TheItemType>*) myCurrent)->Value(); }
|
{ return ((const NCollection_TListNode<TheItemType>*) myCurrent)->Value(); }
|
||||||
//! Variable Value access
|
//! Variable Value access
|
||||||
virtual TheItemType& ChangeValue (void) const
|
TheItemType& ChangeValue (void) const
|
||||||
{ return ((NCollection_TListNode<TheItemType> *)myCurrent)->ChangeValue(); }
|
{ return ((NCollection_TListNode<TheItemType> *)myCurrent)->ChangeValue(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
#define NCollection_TListNode_HeaderFile
|
#define NCollection_TListNode_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_ListNode.hxx>
|
#include <NCollection_ListNode.hxx>
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
|
||||||
#include <NCollection_DefineAlloc.hxx>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: Abstract list node class. Used by BaseList
|
* Purpose: Abstract list node class. Used by BaseList
|
||||||
@ -36,9 +34,7 @@ template <class TheItemType> class NCollection_TListNode
|
|||||||
const TheItemType& Value () const { return myValue; }
|
const TheItemType& Value () const { return myValue; }
|
||||||
//! Variable value access
|
//! Variable value access
|
||||||
TheItemType& ChangeValue () { return myValue; }
|
TheItemType& ChangeValue () { return myValue; }
|
||||||
//! Memory allocation
|
|
||||||
DEFINE_STANDARD_ALLOC
|
|
||||||
DEFINE_NCOLLECTION_ALLOC
|
|
||||||
//! Static deleter to be passed to BaseList
|
//! Static deleter to be passed to BaseList
|
||||||
static void delNode (NCollection_ListNode * theNode,
|
static void delNode (NCollection_ListNode * theNode,
|
||||||
Handle(NCollection_BaseAllocator)& theAl)
|
Handle(NCollection_BaseAllocator)& theAl)
|
||||||
|
@ -62,7 +62,12 @@
|
|||||||
|
|
||||||
template <class TheObjType, class TheBndType> class NCollection_UBTree
|
template <class TheObjType, class TheBndType> class NCollection_UBTree
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! Memory allocation
|
||||||
|
DEFINE_STANDARD_ALLOC
|
||||||
|
DEFINE_NCOLLECTION_ALLOC
|
||||||
|
|
||||||
|
public:
|
||||||
// ---------- PUBLIC TYPES ----------
|
// ---------- PUBLIC TYPES ----------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#define NCollection_Vector_HeaderFile
|
#define NCollection_Vector_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_BaseVector.hxx>
|
#include <NCollection_BaseVector.hxx>
|
||||||
#include <NCollection_BaseCollection.hxx>
|
|
||||||
#include <NCollection_StlIterator.hxx>
|
#include <NCollection_StlIterator.hxx>
|
||||||
|
|
||||||
//! Class NCollection_Vector (dynamic array of objects)
|
//! Class NCollection_Vector (dynamic array of objects)
|
||||||
@ -41,9 +40,8 @@
|
|||||||
//! creation or initialisation of the iterator. Therefore the iteration begins
|
//! creation or initialisation of the iterator. Therefore the iteration begins
|
||||||
//! at index 0 and stops at the index equal to (remembered_length-1). It is OK
|
//! at index 0 and stops at the index equal to (remembered_length-1). It is OK
|
||||||
//! to enlarge the vector during the iteration.
|
//! to enlarge the vector during the iteration.
|
||||||
template <class TheItemType> class NCollection_Vector
|
template <class TheItemType>
|
||||||
: public NCollection_BaseCollection<TheItemType>,
|
class NCollection_Vector : public NCollection_BaseVector
|
||||||
public NCollection_BaseVector
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! STL-compliant typedef for value type
|
//! STL-compliant typedef for value type
|
||||||
@ -52,8 +50,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//! Nested class Iterator
|
//! Nested class Iterator
|
||||||
class Iterator : public NCollection_BaseCollection<TheItemType>::Iterator,
|
class Iterator : public NCollection_BaseVector::Iterator
|
||||||
public NCollection_BaseVector::Iterator
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -82,49 +79,49 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Check end
|
//! Check end
|
||||||
virtual Standard_Boolean More() const
|
Standard_Boolean More() const
|
||||||
{
|
{
|
||||||
return moreV();
|
return moreV();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Increment operator.
|
//! Increment operator.
|
||||||
virtual void Next()
|
void Next()
|
||||||
{
|
{
|
||||||
nextV();
|
nextV();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Decrement operator.
|
//! Decrement operator.
|
||||||
virtual void Previous()
|
void Previous()
|
||||||
{
|
{
|
||||||
prevV();
|
prevV();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Offset operator.
|
//! Offset operator.
|
||||||
virtual void Offset (ptrdiff_t theOffset)
|
void Offset (ptrdiff_t theOffset)
|
||||||
{
|
{
|
||||||
offsetV ((int)theOffset);
|
offsetV (static_cast<int>(theOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Difference operator.
|
//! Difference operator.
|
||||||
virtual ptrdiff_t Differ (const Iterator& theOther) const
|
ptrdiff_t Differ (const Iterator& theOther) const
|
||||||
{
|
{
|
||||||
return differV (theOther);
|
return differV (theOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Constant value access
|
//! Constant value access
|
||||||
virtual const TheItemType& Value() const
|
const TheItemType& Value() const
|
||||||
{
|
{
|
||||||
return ((const TheItemType* )curBlockV()->DataPtr)[myCurIndex];
|
return ((const TheItemType* )curBlockV()->DataPtr)[myCurIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Variable value access
|
//! Variable value access
|
||||||
virtual TheItemType& ChangeValue() const
|
TheItemType& ChangeValue() const
|
||||||
{
|
{
|
||||||
return ((TheItemType* )curBlockV()->DataPtr)[myCurIndex];
|
return ((TheItemType* )curBlockV()->DataPtr)[myCurIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Performs comparison of two iterators.
|
//! Performs comparison of two iterators.
|
||||||
virtual Standard_Boolean IsEqual (const Iterator& theOther) const
|
Standard_Boolean IsEqual (const Iterator& theOther) const
|
||||||
{
|
{
|
||||||
return myVector == theOther.myVector
|
return myVector == theOther.myVector
|
||||||
&& myCurIndex == theOther.myCurIndex
|
&& myCurIndex == theOther.myCurIndex
|
||||||
@ -156,14 +153,13 @@ public: //! @name public methods
|
|||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
NCollection_Vector (const Standard_Integer theIncrement = 256,
|
NCollection_Vector (const Standard_Integer theIncrement = 256,
|
||||||
const Handle(NCollection_BaseAllocator)& theAlloc = NULL)
|
const Handle(NCollection_BaseAllocator)& theAlloc = NULL) :
|
||||||
: NCollection_BaseCollection<TheItemType> (theAlloc),
|
NCollection_BaseVector (theAlloc, initMemBlocks, sizeof(TheItemType), theIncrement)
|
||||||
NCollection_BaseVector (NCollection_BaseCollection<TheItemType>::myAllocator, initMemBlocks, sizeof(TheItemType), theIncrement) {}
|
{}
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
NCollection_Vector (const NCollection_Vector& theOther)
|
NCollection_Vector (const NCollection_Vector& theOther) :
|
||||||
: NCollection_BaseCollection<TheItemType> (theOther.myAllocator),
|
NCollection_BaseVector (theOther.myAllocator, initMemBlocks, theOther)
|
||||||
NCollection_BaseVector (NCollection_BaseCollection<TheItemType>::myAllocator, initMemBlocks, theOther)
|
|
||||||
{
|
{
|
||||||
copyData (theOther);
|
copyData (theOther);
|
||||||
}
|
}
|
||||||
@ -175,14 +171,7 @@ public: //! @name public methods
|
|||||||
{
|
{
|
||||||
initMemBlocks (*this, myData[anItemIter], 0, 0);
|
initMemBlocks (*this, myData[anItemIter], 0, 0);
|
||||||
}
|
}
|
||||||
NCollection_BaseCollection<TheItemType>::myAllocator->Free (myData);
|
this->myAllocator->Free (myData);
|
||||||
}
|
|
||||||
|
|
||||||
//! Operator=
|
|
||||||
NCollection_Vector& operator= (const NCollection_Vector& theOther)
|
|
||||||
{
|
|
||||||
Assign (theOther, Standard_False);
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Total number of items
|
//! Total number of items
|
||||||
@ -192,7 +181,7 @@ public: //! @name public methods
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Total number of items in the vector
|
//! Total number of items in the vector
|
||||||
virtual Standard_Integer Size() const
|
Standard_Integer Size() const
|
||||||
{
|
{
|
||||||
return myLength;
|
return myLength;
|
||||||
}
|
}
|
||||||
@ -217,34 +206,21 @@ public: //! @name public methods
|
|||||||
return (myLength == 0);
|
return (myLength == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Virtual assignment (any collection to this array)
|
|
||||||
virtual void Assign (const NCollection_BaseCollection<TheItemType>& theOther)
|
|
||||||
{
|
|
||||||
if (this != &theOther)
|
|
||||||
{
|
|
||||||
TYPENAME NCollection_BaseCollection<TheItemType>::Iterator& anIter2 = theOther.CreateIterator();
|
|
||||||
while (anIter2.More())
|
|
||||||
{
|
|
||||||
Append (anIter2.Value());
|
|
||||||
anIter2.Next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Assignment to the collection of the same type
|
//! Assignment to the collection of the same type
|
||||||
inline void Assign (const NCollection_Vector& theOther,
|
inline void Assign (const NCollection_Vector& theOther,
|
||||||
const Standard_Boolean theOwnAllocator = Standard_True);
|
const Standard_Boolean theOwnAllocator = Standard_True);
|
||||||
|
|
||||||
//! Method to create iterators for base collections
|
//! Assignment operator
|
||||||
virtual TYPENAME NCollection_BaseCollection<TheItemType>::Iterator& CreateIterator() const
|
NCollection_Vector& operator= (const NCollection_Vector& theOther)
|
||||||
{
|
{
|
||||||
return *(new (this->IterAllocator()) Iterator(*this));
|
Assign (theOther, Standard_False);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Append
|
//! Append
|
||||||
TheItemType& Append (const TheItemType& theValue)
|
TheItemType& Append (const TheItemType& theValue)
|
||||||
{
|
{
|
||||||
TheItemType& anAppended = *(TheItemType* )expandV (NCollection_BaseCollection<TheItemType>::myAllocator, myLength);
|
TheItemType& anAppended = *(TheItemType* )expandV (myLength);
|
||||||
anAppended = theValue;
|
anAppended = theValue;
|
||||||
return anAppended;
|
return anAppended;
|
||||||
}
|
}
|
||||||
@ -300,7 +276,7 @@ public: //! @name public methods
|
|||||||
const TheItemType& theValue)
|
const TheItemType& theValue)
|
||||||
{
|
{
|
||||||
Standard_OutOfRange_Raise_if (theIndex < 0, "NCollection_Vector::SetValue");
|
Standard_OutOfRange_Raise_if (theIndex < 0, "NCollection_Vector::SetValue");
|
||||||
TheItemType* const aVecValue = (TheItemType* )(theIndex < myLength ? findV (theIndex) : expandV (NCollection_BaseCollection<TheItemType>::myAllocator, theIndex));
|
TheItemType* const aVecValue = (TheItemType* )(theIndex < myLength ? findV (theIndex) : expandV (theIndex));
|
||||||
*aVecValue = theValue;
|
*aVecValue = theValue;
|
||||||
return *aVecValue;
|
return *aVecValue;
|
||||||
}
|
}
|
||||||
@ -384,18 +360,18 @@ void NCollection_Vector<TheItemType>::Assign (const NCollection_Vector& theOther
|
|||||||
{
|
{
|
||||||
initMemBlocks (*this, myData[anItemIter], 0, 0);
|
initMemBlocks (*this, myData[anItemIter], 0, 0);
|
||||||
}
|
}
|
||||||
NCollection_BaseCollection<TheItemType>::myAllocator->Free (myData);
|
this->myAllocator->Free (myData);
|
||||||
|
|
||||||
// allocate memory blocks with new allocator
|
// allocate memory blocks with new allocator
|
||||||
if (!theOwnAllocator)
|
if (!theOwnAllocator)
|
||||||
{
|
{
|
||||||
NCollection_BaseCollection<TheItemType>::myAllocator = theOther.myAllocator;
|
this->myAllocator = theOther.myAllocator;
|
||||||
}
|
}
|
||||||
myIncrement = theOther.myIncrement;
|
myIncrement = theOther.myIncrement;
|
||||||
myLength = theOther.myLength;
|
myLength = theOther.myLength;
|
||||||
myNBlocks = (myLength == 0) ? 0 : (1 + (myLength - 1)/myIncrement);
|
myNBlocks = (myLength == 0) ? 0 : (1 + (myLength - 1)/myIncrement);
|
||||||
myCapacity = GetCapacity (myIncrement) + myLength / myIncrement;
|
myCapacity = GetCapacity (myIncrement) + myLength / myIncrement;
|
||||||
myData = allocMemBlocks (NCollection_BaseCollection<TheItemType>::myAllocator, myCapacity);
|
myData = allocMemBlocks (myCapacity);
|
||||||
|
|
||||||
// copy data
|
// copy data
|
||||||
copyData (theOther);
|
copyData (theOther);
|
||||||
|
@ -17,17 +17,8 @@
|
|||||||
#define Prs3d_NListOfSequenceOfPnt_HeaderFile
|
#define Prs3d_NListOfSequenceOfPnt_HeaderFile
|
||||||
|
|
||||||
#include <TColgp_SequenceOfPnt.hxx>
|
#include <TColgp_SequenceOfPnt.hxx>
|
||||||
#include <NCollection_DefineList.hxx>
|
#include <NCollection_List.hxx>
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
|
|
||||||
DEFINE_BASECOLLECTION(Prs3d_BaseCollListOfSequenceOfPnt,
|
typedef NCollection_List<TColgp_SequenceOfPnt> Prs3d_NListOfSequenceOfPnt;
|
||||||
TColgp_SequenceOfPnt)
|
|
||||||
DEFINE_LIST (Prs3d_NListOfSequenceOfPnt,
|
|
||||||
Prs3d_BaseCollListOfSequenceOfPnt,
|
|
||||||
TColgp_SequenceOfPnt)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#ifndef _SelectMgr_DataMapOfObjectOwners_HeaderFile
|
#ifndef _SelectMgr_DataMapOfObjectOwners_HeaderFile
|
||||||
#define _SelectMgr_DataMapOfObjectOwners_HeaderFile
|
#define _SelectMgr_DataMapOfObjectOwners_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineDataMap.hxx>
|
#include <NCollection_DataMap.hxx>
|
||||||
#include <SelectMgr_SelectableObject.hxx>
|
#include <SelectMgr_SelectableObject.hxx>
|
||||||
#include <SelectMgr_SequenceOfOwner.hxx>
|
#include <SelectMgr_SequenceOfOwner.hxx>
|
||||||
|
|
||||||
@ -26,12 +26,7 @@ inline Standard_Boolean IsEqual (const Handle(SelectMgr_SelectableObject)& theH1
|
|||||||
return (theH1 == theH2);
|
return (theH1 == theH2);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_BASECOLLECTION(SelectMgr_CollectionOfSequenceOfOwner, SelectMgr_SequenceOfOwner)
|
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), SelectMgr_SequenceOfOwner> SelectMgr_DataMapOfObjectOwners;
|
||||||
DEFINE_DATAMAP(SelectMgr_DataMapOfObjectOwners, SelectMgr_CollectionOfSequenceOfOwner,
|
typedef SelectMgr_DataMapOfObjectOwners::Iterator SelectMgr_DataMapIteratorOfMapOfObjectOwners;
|
||||||
Handle(SelectMgr_SelectableObject), SelectMgr_SequenceOfOwner)
|
|
||||||
|
|
||||||
typedef SelectMgr_DataMapOfObjectOwners::Iterator
|
|
||||||
SelectMgr_DataMapIteratorOfMapOfObjectOwners;
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,10 +18,7 @@
|
|||||||
#ifndef TObj_Container_HeaderFile
|
#ifndef TObj_Container_HeaderFile
|
||||||
#define TObj_Container_HeaderFile
|
#define TObj_Container_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
#include <NCollection_DataMap.hxx>
|
||||||
#include <NCollection_DefineDataMap.hxx>
|
|
||||||
#include <NCollection_DefineSequence.hxx>
|
|
||||||
#include <NCollection_DefineHSequence.hxx>
|
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
#include <TCollection_HExtendedString.hxx>
|
#include <TCollection_HExtendedString.hxx>
|
||||||
#include <TDF_Label.hxx>
|
#include <TDF_Label.hxx>
|
||||||
@ -29,21 +26,10 @@
|
|||||||
#include <TObj_Common.hxx>
|
#include <TObj_Common.hxx>
|
||||||
#include <TObj_SequenceOfObject.hxx>
|
#include <TObj_SequenceOfObject.hxx>
|
||||||
|
|
||||||
DEFINE_BASECOLLECTION (TObj_CollectionOfLabel, TDF_Label)
|
typedef NCollection_DataMap<Handle(TCollection_HExtendedString), TDF_Label> TObj_DataMapOfNameLabel;
|
||||||
|
|
||||||
DEFINE_BASECOLLECTION(TObj_CollectionOfPointer, Standard_Address)
|
typedef NCollection_DataMap<Handle(TObj_Object), Handle(TObj_HSequenceOfObject)> TObj_DataMapOfObjectHSequenceOcafObjects;
|
||||||
|
|
||||||
DEFINE_BASECOLLECTION (TObj_CollectionOfHSeqOfObject,
|
typedef NCollection_DataMap<TCollection_AsciiString, Standard_Address> TObj_DataMapOfStringPointer;
|
||||||
Handle(TObj_HSequenceOfObject))
|
|
||||||
|
|
||||||
DEFINE_DATAMAP (TObj_DataMapOfNameLabel, TObj_CollectionOfLabel,
|
|
||||||
Handle(TCollection_HExtendedString), TDF_Label)
|
|
||||||
|
|
||||||
|
|
||||||
DEFINE_DATAMAP (TObj_DataMapOfObjectHSequenceOcafObjects,
|
|
||||||
TObj_CollectionOfHSeqOfObject,
|
|
||||||
Handle(TObj_Object),Handle(TObj_HSequenceOfObject))
|
|
||||||
|
|
||||||
DEFINE_DATAMAP(TObj_DataMapOfStringPointer,TObj_CollectionOfPointer,
|
|
||||||
TCollection_AsciiString,Standard_Address)
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
#include <TDF_Label.hxx>
|
#include <TDF_Label.hxx>
|
||||||
#include <TObj_Partition.hxx>
|
#include <TObj_Partition.hxx>
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
|
||||||
#include <NCollection_DefineDataMap.hxx>
|
|
||||||
#include <Message_Messenger.hxx>
|
#include <Message_Messenger.hxx>
|
||||||
|
|
||||||
class Handle(TObj_Application);
|
class Handle(TObj_Application);
|
||||||
@ -364,7 +362,3 @@ class TObj_Model : public MMgt_TShared
|
|||||||
//! The Model Handle is defined in a separate header file
|
//! The Model Handle is defined in a separate header file
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
@ -18,17 +18,9 @@
|
|||||||
#ifndef TObj_SequenceOfIterator_HeaderFile
|
#ifndef TObj_SequenceOfIterator_HeaderFile
|
||||||
#define TObj_SequenceOfIterator_HeaderFile
|
#define TObj_SequenceOfIterator_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
#include <NCollection_Sequence.hxx>
|
||||||
#include <NCollection_DefineSequence.hxx>
|
|
||||||
|
|
||||||
#include <TObj_ObjectIterator.hxx>
|
#include <TObj_ObjectIterator.hxx>
|
||||||
|
|
||||||
DEFINE_BASECOLLECTION (TObj_CollectionOfIterator, Handle(TObj_ObjectIterator))
|
typedef NCollection_Sequence<Handle(TObj_ObjectIterator)> TObj_SequenceOfIterator;
|
||||||
DEFINE_SEQUENCE (TObj_SequenceOfIterator, TObj_CollectionOfIterator,
|
|
||||||
Handle(TObj_ObjectIterator))
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
@ -18,19 +18,14 @@
|
|||||||
#ifndef TObj_SequenceOfObject_HeaderFile
|
#ifndef TObj_SequenceOfObject_HeaderFile
|
||||||
#define TObj_SequenceOfObject_HeaderFile
|
#define TObj_SequenceOfObject_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
#include <NCollection_Sequence.hxx>
|
||||||
#include <NCollection_DefineSequence.hxx>
|
|
||||||
#include <NCollection_DefineHSequence.hxx>
|
#include <NCollection_DefineHSequence.hxx>
|
||||||
|
|
||||||
#include <TObj_Common.hxx>
|
#include <TObj_Common.hxx>
|
||||||
#include <Handle_TObj_Object.hxx>
|
#include <Handle_TObj_Object.hxx>
|
||||||
|
|
||||||
DEFINE_BASECOLLECTION (TObj_CollectionOfObject,Handle(TObj_Object))
|
typedef NCollection_Sequence<Handle(TObj_Object)> TObj_SequenceOfObject;
|
||||||
|
|
||||||
DEFINE_SEQUENCE (TObj_SequenceOfObject,
|
DEFINE_HSEQUENCE (TObj_HSequenceOfObject, TObj_SequenceOfObject)
|
||||||
TObj_CollectionOfObject,Handle(TObj_Object))
|
|
||||||
|
|
||||||
DEFINE_HSEQUENCE (TObj_HSequenceOfObject,
|
|
||||||
TObj_SequenceOfObject)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -164,5 +164,5 @@ const TObj_DataMapOfNameLabel& TObj_TNameContainer::Get() const
|
|||||||
void TObj_TNameContainer::Set(const TObj_DataMapOfNameLabel& theMap)
|
void TObj_TNameContainer::Set(const TObj_DataMapOfNameLabel& theMap)
|
||||||
{
|
{
|
||||||
Backup();
|
Backup();
|
||||||
myMap = theMap;
|
myMap.Assign (theMap);
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,9 @@
|
|||||||
#ifndef _Visual3d_NListOfLayerItem_HeaderFile
|
#ifndef _Visual3d_NListOfLayerItem_HeaderFile
|
||||||
#define _Visual3d_NListOfLayerItem_HeaderFile
|
#define _Visual3d_NListOfLayerItem_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_DefineList.hxx>
|
#include <NCollection_List.hxx>
|
||||||
#include <Visual3d_LayerItem.hxx>
|
#include <Visual3d_LayerItem.hxx>
|
||||||
|
|
||||||
DEFINE_LIST (Visual3d_NListOfLayerItem,
|
typedef NCollection_List<Handle(Visual3d_LayerItem)> Visual3d_NListOfLayerItem;
|
||||||
NCollection_List,
|
|
||||||
Handle(Visual3d_LayerItem))
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,12 +36,10 @@ inline Standard_Boolean IsEqual(const iXYZ& one, const iXYZ& two)
|
|||||||
return one.ix == two.ix && one.iy == two.iy && one.iz == two.iz;
|
return one.ix == two.ix && one.iy == two.iy && one.iz == two.iz;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <NCollection_DefineBaseCollection.hxx>
|
#include <NCollection_DataMap.hxx>
|
||||||
DEFINE_BASECOLLECTION(iXYZbase, iXYZ)
|
|
||||||
|
|
||||||
#include <NCollection_DefineDataMap.hxx>
|
typedef NCollection_DataMap<iXYZ, Standard_Integer> iXYZIndex;
|
||||||
DEFINE_DATAMAP(iXYZIndex, iXYZbase, iXYZ, Standard_Integer)
|
typedef NCollection_DataMap<iXYZ, Standard_Byte> iXYZBool;
|
||||||
DEFINE_DATAMAP(iXYZBool, iXYZbase, iXYZ, Standard_Byte)
|
|
||||||
|
|
||||||
// Defines
|
// Defines
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <Standard_OStream.hxx>
|
#include <Standard_OStream.hxx>
|
||||||
#include <Standard_IStream.hxx>
|
#include <Standard_IStream.hxx>
|
||||||
#include <TCollection_ExtendedString.hxx>
|
#include <TCollection_ExtendedString.hxx>
|
||||||
|
#include <NCollection_IncAllocator.hxx>
|
||||||
#include <Standard_Mutex.hxx>
|
#include <Standard_Mutex.hxx>
|
||||||
|
|
||||||
struct VrmlData_InBuffer;
|
struct VrmlData_InBuffer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user