mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0024971: Incomplete interface of NCollection classes
NCollection classes amended to be compatible with TCollection equivalents: - List and Maps: copy constructor is used for placement of new items in collection instead of assignment operator, thus default constructor is not necessary any more for the item class - Constructors with additional argument of element type added in array classes operated by Handle, defined by NCollection_DefineHArray*.hxx, allowing to initialize array immediately by specified value - Non-const methods First() and Last() are added in List class, and method Value() in TListIterator class - Method Append() accepting Handle(HSequence) provided in NCollection_DefineHSequence.hxx - Default implementation of global function IsEqual() is provided as template (using operator ==) Code using lists and maps of sequences is refactored to operate sequence by Handle (since Sequence does not to have public copy constructor). In addition, error checking code is simplified to use macros _Raise_if instead of custom #ifdefs with the same meaning. Comments within declaration of instances of generic classes in CDL removed. Fixed bug in copy constructor of NCollection_BaseVector leading to corrupt data if original vector is empty; simplistic test command for vectors is added.
This commit is contained in:
@@ -16,11 +16,9 @@
|
||||
#ifndef NCollection_Array1_HeaderFile
|
||||
#define NCollection_Array1_HeaderFile
|
||||
|
||||
#ifndef No_Exception
|
||||
#include <Standard_DimensionMismatch.hxx>
|
||||
#include <Standard_OutOfMemory.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#endif
|
||||
|
||||
#include <NCollection_DefineAlloc.hxx>
|
||||
#include <NCollection_StlIterator.hxx>
|
||||
@@ -163,15 +161,9 @@ public:
|
||||
myUpperBound (theUpper),
|
||||
myDeletable (Standard_True)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_RangeError
|
||||
if (theUpper < theLower)
|
||||
Standard_RangeError::Raise ("NCollection_Array1::Create");
|
||||
#endif
|
||||
Standard_RangeError_Raise_if (theUpper < theLower, "NCollection_Array1::Create");
|
||||
TheItemType* pBegin = new TheItemType[Length()];
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfMemory
|
||||
if (!pBegin)
|
||||
Standard_OutOfMemory::Raise ("NCollection_Array1 : Allocation failed");
|
||||
#endif
|
||||
Standard_OutOfMemory_Raise_if (!pBegin, "NCollection_Array1 : Allocation failed");
|
||||
|
||||
myData = pBegin - theLower;
|
||||
}
|
||||
@@ -183,10 +175,7 @@ public:
|
||||
myDeletable (Standard_True)
|
||||
{
|
||||
TheItemType* pBegin = new TheItemType[Length()];
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfMemory
|
||||
if (!pBegin)
|
||||
Standard_OutOfMemory::Raise ("NCollection_Array1 : Allocation failed");
|
||||
#endif
|
||||
Standard_OutOfMemory_Raise_if (!pBegin, "NCollection_Array1 : Allocation failed");
|
||||
myData = pBegin - myLowerBound;
|
||||
|
||||
*this = theOther;
|
||||
@@ -200,10 +189,7 @@ public:
|
||||
myUpperBound (theUpper),
|
||||
myDeletable (Standard_False)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_RangeError
|
||||
if (theUpper < theLower)
|
||||
Standard_RangeError::Raise ("NCollection_Array1::Array1");
|
||||
#endif
|
||||
Standard_RangeError_Raise_if (theUpper < theLower, "NCollection_Array1::Create");
|
||||
myData = (TheItemType *) &theBegin - theLower;
|
||||
}
|
||||
|
||||
@@ -242,10 +228,7 @@ public:
|
||||
{
|
||||
if (&theOther == this)
|
||||
return *this;
|
||||
#if !defined No_Exception && !defined No_Standard_DimensionMismatch
|
||||
if (Length() != theOther.Length())
|
||||
Standard_DimensionMismatch::Raise ("NCollection_Array1::operator=");
|
||||
#endif
|
||||
Standard_DimensionMismatch_Raise_if (Length() != theOther.Length(), "NCollection_Array1::operator=");
|
||||
TheItemType * pMyItem = &myData[myLowerBound];
|
||||
TheItemType * const pEndItem = &(theOther.myData)[theOther.myUpperBound];
|
||||
TheItemType * pItem = &(theOther.myData)[theOther.myLowerBound];
|
||||
@@ -286,10 +269,7 @@ public:
|
||||
//! Constant value access
|
||||
const TheItemType& Value (const Standard_Integer theIndex) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theIndex < myLowerBound || theIndex > myUpperBound)
|
||||
Standard_OutOfRange::Raise ("NCollection_Array1::Value");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theIndex < myLowerBound || theIndex > myUpperBound, "NCollection_Array1::Value");
|
||||
return myData[theIndex];
|
||||
}
|
||||
|
||||
@@ -300,10 +280,7 @@ public:
|
||||
//! Variable value access
|
||||
TheItemType& ChangeValue (const Standard_Integer theIndex)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theIndex < myLowerBound || theIndex > myUpperBound)
|
||||
Standard_OutOfRange::Raise ("NCollection_Array1::ChangeValue");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theIndex < myLowerBound || theIndex > myUpperBound, "NCollection_Array1::ChangeValue");
|
||||
return myData[theIndex];
|
||||
}
|
||||
|
||||
@@ -315,10 +292,7 @@ public:
|
||||
void SetValue (const Standard_Integer theIndex,
|
||||
const TheItemType& theItem)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theIndex < myLowerBound || theIndex > myUpperBound)
|
||||
Standard_OutOfRange::Raise ("NCollection_Array1::SetValue");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theIndex < myLowerBound || theIndex > myUpperBound, "NCollection_Array1::SetValue");
|
||||
myData[theIndex] = theItem;
|
||||
}
|
||||
|
||||
|
@@ -16,11 +16,9 @@
|
||||
#ifndef NCollection_Array2_HeaderFile
|
||||
#define NCollection_Array2_HeaderFile
|
||||
|
||||
#ifndef No_Exception
|
||||
#include <Standard_DimensionMismatch.hxx>
|
||||
#include <Standard_OutOfMemory.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#endif
|
||||
|
||||
#include <NCollection_DefineAlloc.hxx>
|
||||
|
||||
@@ -171,10 +169,7 @@ public:
|
||||
{
|
||||
if (&theOther == this)
|
||||
return *this;
|
||||
#if !defined No_Exception && !defined No_Standard_DimensionMismatch
|
||||
if (Length() != theOther.Length())
|
||||
Standard_DimensionMismatch::Raise ("NCollection_Array2::operator=");
|
||||
#endif
|
||||
Standard_DimensionMismatch_Raise_if (Length() != theOther.Length(), "NCollection_Array2::operator=");
|
||||
TheItemType * pMyItem = myStart;
|
||||
TheItemType * pItem = theOther.myStart;
|
||||
const Standard_Integer iSize = Length();
|
||||
@@ -193,11 +188,8 @@ public:
|
||||
const TheItemType& Value (const Standard_Integer theRow,
|
||||
const Standard_Integer theCol) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theRow < myLowerRow || theRow > myUpperRow ||
|
||||
theCol < myLowerCol || theCol > myUpperCol)
|
||||
Standard_OutOfRange::Raise ("NCollection_Array2::Value");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theRow < myLowerRow || theRow > myUpperRow ||
|
||||
theCol < myLowerCol || theCol > myUpperCol, "NCollection_Array2::Value");
|
||||
return myData[theRow][theCol];
|
||||
}
|
||||
|
||||
@@ -210,11 +202,8 @@ public:
|
||||
TheItemType& ChangeValue (const Standard_Integer theRow,
|
||||
const Standard_Integer theCol)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theRow < myLowerRow || theRow > myUpperRow ||
|
||||
theCol < myLowerCol || theCol > myUpperCol)
|
||||
Standard_OutOfRange::Raise ("NCollection_Array2::ChangeValue");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theRow < myLowerRow || theRow > myUpperRow ||
|
||||
theCol < myLowerCol || theCol > myUpperCol, "NCollection_Array2::ChangeValue");
|
||||
return myData[theRow][theCol];
|
||||
}
|
||||
|
||||
@@ -228,11 +217,8 @@ public:
|
||||
const Standard_Integer theCol,
|
||||
const TheItemType& theItem)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theRow < myLowerRow || theRow > myUpperRow ||
|
||||
theCol < myLowerCol || theCol > myUpperCol)
|
||||
Standard_OutOfRange::Raise ("NCollection_Array2::SetValue");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theRow < myLowerRow || theRow > myUpperRow ||
|
||||
theCol < myLowerCol || theCol > myUpperCol, "NCollection_Array2::SetValue");
|
||||
myData[theRow][theCol] = theItem;
|
||||
}
|
||||
|
||||
@@ -251,24 +237,15 @@ public:
|
||||
{
|
||||
const Standard_Integer iRowSize = myUpperCol - myLowerCol + 1;
|
||||
const Standard_Integer iColSize = myUpperRow - myLowerRow + 1;
|
||||
#if !defined No_Exception && !defined No_Standard_RangeError
|
||||
if (iRowSize <= 0 || iColSize <= 0)
|
||||
Standard_RangeError::Raise ("NCollection_Array2::Allocate");
|
||||
#endif
|
||||
Standard_RangeError_Raise_if (iRowSize <= 0 || iColSize <= 0, "NCollection_Array2::Allocate");
|
||||
if (myDeletable) {
|
||||
// allocation of the data in the array
|
||||
myStart = new TheItemType[iRowSize * iColSize];
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfMemory
|
||||
if (!myStart)
|
||||
Standard_OutOfMemory::Raise ("NCollection_Array2 : Allocation failed");
|
||||
#endif
|
||||
Standard_OutOfMemory_Raise_if (!myStart, "NCollection_Array2 : Allocation failed");
|
||||
}
|
||||
// else myStart is set to the beginning of the given array
|
||||
TheItemType** pTable = new TheItemType* [iColSize];
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfMemory
|
||||
if (!pTable)
|
||||
Standard_OutOfMemory::Raise ("NCollection_Array2 : Allocation failed");
|
||||
#endif
|
||||
Standard_OutOfMemory_Raise_if (!pTable, "NCollection_Array2 : Allocation failed");
|
||||
|
||||
// Items of pTable point to the '0'th items in the rows of the array
|
||||
TheItemType* pRow = myStart - myLowerCol;
|
||||
|
@@ -177,7 +177,7 @@ protected: //! @name protected methods
|
||||
myIncrement (theOther.myIncrement),
|
||||
myLength (theOther.myLength),
|
||||
myCapacity (GetCapacity(myIncrement) + theOther.myLength / theOther.myIncrement),
|
||||
myNBlocks (1 + (theOther.myLength - 1)/theOther.myIncrement),
|
||||
myNBlocks (theOther.myLength == 0 ? 0 : 1 + (theOther.myLength - 1)/theOther.myIncrement),
|
||||
myInitBlocks (theInitBlocks)
|
||||
{
|
||||
myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
|
||||
|
@@ -56,8 +56,10 @@ class NCollection_DataMap : public NCollection_BaseMap
|
||||
DataMapNode (const TheKeyType& theKey,
|
||||
const TheItemType& theItem,
|
||||
NCollection_ListNode* theNext) :
|
||||
NCollection_TListNode<TheItemType> (theItem, theNext)
|
||||
{ myKey = theKey; }
|
||||
NCollection_TListNode<TheItemType> (theItem, theNext),
|
||||
myKey(theKey)
|
||||
{}
|
||||
|
||||
//! Key
|
||||
const TheKeyType& Key (void) const
|
||||
{ return myKey; }
|
||||
@@ -94,28 +96,19 @@ class NCollection_DataMap : public NCollection_BaseMap
|
||||
//! Value inquiry
|
||||
const TheItemType& Value(void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise("NCollection_DataMap::Iterator::Value");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if(!More(), "NCollection_DataMap::Iterator::Value");
|
||||
return ((DataMapNode *) myNode)->Value();
|
||||
}
|
||||
//! Value change access
|
||||
TheItemType& ChangeValue(void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise("NCollection_DataMap::Iterator::ChangeValue");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if(!More(), "NCollection_DataMap::Iterator::ChangeValue");
|
||||
return ((DataMapNode *) myNode)->ChangeValue();
|
||||
}
|
||||
//! Key
|
||||
const TheKeyType& Key (void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise("NCollection_DataMap::Iterator::Key");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if(!More(), "NCollection_DataMap::Iterator::Key");
|
||||
return ((DataMapNode *) myNode)->Key();
|
||||
}
|
||||
};
|
||||
@@ -280,10 +273,7 @@ class NCollection_DataMap : public NCollection_BaseMap
|
||||
//! Find
|
||||
const TheItemType& Find(const TheKeyType& theKey) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (IsEmpty())
|
||||
Standard_NoSuchObject::Raise ("NCollection_DataMap::Find");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DataMap::Find");
|
||||
DataMapNode* p = (DataMapNode*) myData1[Hasher::HashCode(theKey,NbBuckets())];
|
||||
while (p)
|
||||
{
|
||||
@@ -325,10 +315,7 @@ class NCollection_DataMap : public NCollection_BaseMap
|
||||
//! ChangeFind
|
||||
TheItemType& ChangeFind (const TheKeyType& theKey)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (IsEmpty())
|
||||
Standard_NoSuchObject::Raise ("NCollection_DataMap::Find");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DataMap::Find");
|
||||
DataMapNode* p = (DataMapNode*) myData1[Hasher::HashCode(theKey,NbBuckets())];
|
||||
while (p)
|
||||
{
|
||||
|
@@ -22,20 +22,36 @@
|
||||
//function : HashCode_Proxy
|
||||
//purpose : Function is required to call the global function HashCode.
|
||||
//=======================================================================
|
||||
|
||||
template <class TheKeyType>
|
||||
static Standard_Integer HashCode_Proxy(const TheKeyType& theKey,
|
||||
const Standard_Integer Upper) {
|
||||
return HashCode(theKey, Upper);
|
||||
inline Standard_Integer HashCode_Proxy (const TheKeyType& theKey,
|
||||
const Standard_Integer Upper)
|
||||
{
|
||||
return HashCode (theKey, Upper);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsEqual
|
||||
//purpose : Default implementation of IsEqual via operator ==
|
||||
//=======================================================================
|
||||
|
||||
template <class TheKeyType>
|
||||
inline Standard_Boolean IsEqual (const TheKeyType& theKey1,
|
||||
const TheKeyType& theKey2)
|
||||
{
|
||||
return theKey1 == theKey2;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsEqual_Proxy
|
||||
//purpose : Function is required to call the global function IsEqual.
|
||||
//=======================================================================
|
||||
|
||||
template <class TheKeyType>
|
||||
static Standard_Boolean IsEqual_Proxy(const TheKeyType& theKey1,
|
||||
const TheKeyType& theKey2) {
|
||||
return IsEqual(theKey1, theKey2);
|
||||
inline Standard_Boolean IsEqual_Proxy (const TheKeyType& theKey1,
|
||||
const TheKeyType& theKey2)
|
||||
{
|
||||
return IsEqual (theKey1, theKey2);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -25,36 +25,23 @@
|
||||
// Declaration of Array1 class managed by Handle
|
||||
|
||||
#define DEFINE_HARRAY1(HClassName, _Array1Type_) \
|
||||
\
|
||||
class HClassName : public _Array1Type_, \
|
||||
public MMgt_TShared { \
|
||||
class HClassName : public _Array1Type_, public MMgt_TShared { \
|
||||
public: \
|
||||
DEFINE_STANDARD_ALLOC \
|
||||
DEFINE_NCOLLECTION_ALLOC \
|
||||
inline HClassName (const Standard_Integer theLower, \
|
||||
const Standard_Integer theUpper); \
|
||||
inline HClassName (const _Array1Type_&); \
|
||||
inline const _Array1Type_& Array1 () const; \
|
||||
inline _Array1Type_& ChangeArray1 (); \
|
||||
DEFINE_STANDARD_RTTI (HClassName) \
|
||||
HClassName (const Standard_Integer theLower, \
|
||||
const Standard_Integer theUpper) : \
|
||||
_Array1Type_ (theLower,theUpper) {} \
|
||||
HClassName (const Standard_Integer theLower, \
|
||||
const Standard_Integer theUpper, \
|
||||
const _Array1Type_::value_type& theValue) : \
|
||||
_Array1Type_ (theLower,theUpper) { Init (theValue); } \
|
||||
HClassName (const _Array1Type_& theOther) : _Array1Type_(theOther) {} \
|
||||
const _Array1Type_& Array1 () const { return *this; } \
|
||||
_Array1Type_& ChangeArray1 () { return *this; } \
|
||||
DEFINE_STANDARD_RTTI (HClassName) \
|
||||
}; \
|
||||
\
|
||||
DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared) \
|
||||
\
|
||||
inline HClassName::HClassName (const Standard_Integer theLower, \
|
||||
const Standard_Integer theUpper) : \
|
||||
_Array1Type_ (theLower,theUpper), \
|
||||
MMgt_TShared() {} \
|
||||
\
|
||||
inline HClassName::HClassName (const _Array1Type_& theOther) : \
|
||||
_Array1Type_(theOther), \
|
||||
MMgt_TShared() {} \
|
||||
\
|
||||
inline const _Array1Type_& HClassName::Array1 () const \
|
||||
{ return * (const _Array1Type_ *) this; } \
|
||||
\
|
||||
inline _Array1Type_& HClassName::ChangeArray1 () \
|
||||
{ return * (_Array1Type_ *) this; } \
|
||||
DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared)
|
||||
|
||||
#define IMPLEMENT_HARRAY1(HClassName) \
|
||||
IMPLEMENT_STANDARD_HANDLE (HClassName, MMgt_TShared) \
|
||||
|
@@ -25,40 +25,28 @@
|
||||
// Declaration of Array2 class managed by Handle
|
||||
|
||||
#define DEFINE_HARRAY2(HClassName, _Array2Type_) \
|
||||
\
|
||||
class HClassName : public _Array2Type_, \
|
||||
public MMgt_TShared { \
|
||||
class HClassName : public _Array2Type_, public MMgt_TShared { \
|
||||
public: \
|
||||
DEFINE_STANDARD_ALLOC \
|
||||
DEFINE_NCOLLECTION_ALLOC \
|
||||
inline HClassName (const Standard_Integer theRowLower, \
|
||||
const Standard_Integer theRowUpper, \
|
||||
const Standard_Integer theColLower, \
|
||||
const Standard_Integer theColUpper);\
|
||||
inline HClassName (const _Array2Type_&); \
|
||||
inline const _Array2Type_& Array2 () const; \
|
||||
inline _Array2Type_& ChangeArray2(); \
|
||||
DEFINE_STANDARD_RTTI (HClassName) \
|
||||
HClassName (const Standard_Integer theRowLow, \
|
||||
const Standard_Integer theRowUpp, \
|
||||
const Standard_Integer theColLow, \
|
||||
const Standard_Integer theColUpp) : \
|
||||
_Array2Type_ (theRowLow, theRowUpp, theColLow, theColUpp) {} \
|
||||
HClassName (const Standard_Integer theRowLow, \
|
||||
const Standard_Integer theRowUpp, \
|
||||
const Standard_Integer theColLow, \
|
||||
const Standard_Integer theColUpp, \
|
||||
const _Array2Type_::value_type& theValue) : \
|
||||
_Array2Type_ (theRowLow, theRowUpp, theColLow, theColUpp) \
|
||||
{ Init (theValue); } \
|
||||
HClassName (const _Array2Type_& theOther) : _Array2Type_(theOther) {} \
|
||||
const _Array2Type_& Array2 () const { return *this; } \
|
||||
_Array2Type_& ChangeArray2 () { return *this; } \
|
||||
DEFINE_STANDARD_RTTI (HClassName) \
|
||||
}; \
|
||||
\
|
||||
DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared) \
|
||||
\
|
||||
inline HClassName::HClassName (const Standard_Integer theRowLow, \
|
||||
const Standard_Integer theRowUpp, \
|
||||
const Standard_Integer theColLow, \
|
||||
const Standard_Integer theColUpp) : \
|
||||
_Array2Type_ (theRowLow, theRowUpp, theColLow, theColUpp), \
|
||||
MMgt_TShared() {} \
|
||||
\
|
||||
inline HClassName::HClassName (const _Array2Type_& theOther) : \
|
||||
_Array2Type_(theOther), \
|
||||
MMgt_TShared() {} \
|
||||
\
|
||||
inline const _Array2Type_& HClassName::Array2 () const \
|
||||
{ return * (const _Array2Type_ *) this; } \
|
||||
\
|
||||
inline _Array2Type_& HClassName::ChangeArray2 () \
|
||||
{ return * (_Array2Type_ *) this; } \
|
||||
DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared)
|
||||
|
||||
#define IMPLEMENT_HARRAY2(HClassName) \
|
||||
IMPLEMENT_STANDARD_HANDLE (HClassName, MMgt_TShared) \
|
||||
|
@@ -25,34 +25,26 @@
|
||||
// Declaration of Sequence class managed by Handle
|
||||
|
||||
#define DEFINE_HSEQUENCE(HClassName, _SequenceType_) \
|
||||
\
|
||||
class HClassName : public _SequenceType_, \
|
||||
public MMgt_TShared { \
|
||||
DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared) \
|
||||
class HClassName : public _SequenceType_, public MMgt_TShared { \
|
||||
public: \
|
||||
DEFINE_STANDARD_ALLOC \
|
||||
DEFINE_NCOLLECTION_ALLOC \
|
||||
inline HClassName (); \
|
||||
inline HClassName (const _SequenceType_&); \
|
||||
inline const _SequenceType_& Sequence () const; \
|
||||
inline _SequenceType_& ChangeSequence (); \
|
||||
DEFINE_STANDARD_RTTI (HClassName) \
|
||||
}; \
|
||||
\
|
||||
DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared) \
|
||||
\
|
||||
inline HClassName::HClassName () : \
|
||||
_SequenceType_(), \
|
||||
MMgt_TShared() {} \
|
||||
\
|
||||
inline HClassName::HClassName (const _SequenceType_& anOther) : \
|
||||
_SequenceType_(anOther), \
|
||||
MMgt_TShared() {} \
|
||||
\
|
||||
inline const _SequenceType_& HClassName::Sequence () const \
|
||||
{ return * (const _SequenceType_ *) this; } \
|
||||
\
|
||||
inline _SequenceType_& HClassName::ChangeSequence () \
|
||||
{ return * (_SequenceType_ *) this; } \
|
||||
HClassName () {} \
|
||||
HClassName (const _SequenceType_& theOther) : _SequenceType_(theOther) {} \
|
||||
const _SequenceType_& Sequence () const { return *this; } \
|
||||
void Append (const _SequenceType_::value_type& theItem) { \
|
||||
_SequenceType_::Append (theItem); \
|
||||
} \
|
||||
void Append (_SequenceType_& theSequence) { \
|
||||
_SequenceType_::Append (theSequence); \
|
||||
} \
|
||||
_SequenceType_& ChangeSequence () { return *this; } \
|
||||
void Append (const Handle(HClassName)& theOther) { \
|
||||
_SequenceType_::Append (theOther->ChangeSequence()); \
|
||||
} \
|
||||
DEFINE_STANDARD_RTTI (HClassName) \
|
||||
};
|
||||
|
||||
#define IMPLEMENT_HSEQUENCE(HClassName) \
|
||||
IMPLEMENT_STANDARD_HANDLE (HClassName, MMgt_TShared) \
|
||||
|
@@ -50,10 +50,10 @@ class NCollection_DoubleMap : public NCollection_BaseMap
|
||||
const TheKey2Type& theKey2,
|
||||
NCollection_ListNode* theNext1,
|
||||
NCollection_ListNode* theNext2) :
|
||||
NCollection_TListNode<TheKey2Type> (theKey2, theNext1)
|
||||
NCollection_TListNode<TheKey2Type> (theKey2, theNext1),
|
||||
myKey1(theKey1),
|
||||
myNext2((DoubleMapNode*)theNext2)
|
||||
{
|
||||
myKey1 = theKey1;
|
||||
myNext2 = (DoubleMapNode *) theNext2;
|
||||
}
|
||||
//! Key1
|
||||
const TheKey1Type& Key1 (void)
|
||||
@@ -97,28 +97,19 @@ class NCollection_DoubleMap : public NCollection_BaseMap
|
||||
//! Key1 inquiry
|
||||
const TheKey1Type& Key1(void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise ("NCollection_DoubleMap::Iterator::Key1");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (!More(), "NCollection_DoubleMap::Iterator::Key1");
|
||||
return ((DoubleMapNode *) myNode)->Key1();
|
||||
}
|
||||
//! Key2 inquiry
|
||||
const TheKey2Type& Key2(void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise ("NCollection_DoubleMap::Iterator::Key2");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (!More(), "NCollection_DoubleMap::Iterator::Key2");
|
||||
return ((DoubleMapNode *) myNode)->Key2();
|
||||
}
|
||||
//! Value access
|
||||
const TheKey2Type& Value(void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise ("NCollection_DoubleMap::Iterator::Value");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (!More(), "NCollection_DoubleMap::Iterator::Value");
|
||||
return ((DoubleMapNode *) myNode)->Value();
|
||||
}
|
||||
//! Value change access - denied
|
||||
@@ -402,10 +393,7 @@ class NCollection_DoubleMap : public NCollection_BaseMap
|
||||
//! Find1
|
||||
const TheKey2Type& Find1(const TheKey1Type& theKey1) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (IsEmpty())
|
||||
Standard_NoSuchObject::Raise ("NCollection_DoubleMap::Find1");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DoubleMap::Find1");
|
||||
DoubleMapNode * pNode1 =
|
||||
(DoubleMapNode *) myData1[Hasher1::HashCode(theKey1,NbBuckets())];
|
||||
while (pNode1)
|
||||
@@ -421,10 +409,7 @@ class NCollection_DoubleMap : public NCollection_BaseMap
|
||||
//! Find2
|
||||
const TheKey1Type& Find2(const TheKey2Type& theKey2) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (IsEmpty())
|
||||
Standard_NoSuchObject::Raise ("NCollection_DoubleMap::Find2");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DoubleMap::Find2");
|
||||
DoubleMapNode * pNode2 =
|
||||
(DoubleMapNode *) myData2[Hasher2::HashCode(theKey2,NbBuckets())];
|
||||
while (pNode2)
|
||||
|
@@ -23,9 +23,7 @@
|
||||
#include <NCollection_StlIterator.hxx>
|
||||
#include <NCollection_DefaultHasher.hxx>
|
||||
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Purpose: An indexed map is used to store keys and to bind
|
||||
@@ -62,11 +60,11 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||
const TheItemType& theItem,
|
||||
NCollection_ListNode* theNext1,
|
||||
NCollection_ListNode* theNext2) :
|
||||
NCollection_TListNode<TheItemType>(theItem,theNext1)
|
||||
NCollection_TListNode<TheItemType>(theItem,theNext1),
|
||||
myKey1(theKey1),
|
||||
myKey2(theKey2),
|
||||
myNext2((IndexedDataMapNode*)theNext2)
|
||||
{
|
||||
myKey1 = theKey1;
|
||||
myKey2 = theKey2;
|
||||
myNext2 = (IndexedDataMapNode *) theNext2;
|
||||
}
|
||||
//! Key1
|
||||
TheKeyType& Key1 (void)
|
||||
@@ -116,28 +114,19 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||
//! Value access
|
||||
const TheItemType& Value(void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::Iterator::Value");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if(!More(), "NCollection_IndexedDataMap::Iterator::Value");
|
||||
return myNode->Value();
|
||||
}
|
||||
//! ChangeValue access
|
||||
TheItemType& ChangeValue(void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::Iterator::ChangeValue");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if(!More(), "NCollection_IndexedDataMap::Iterator::ChangeValue");
|
||||
return myNode->ChangeValue();
|
||||
}
|
||||
//! Key
|
||||
const TheKeyType& Key() const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise("NCollection_DataMap::Iterator::Key");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if(!More(), "NCollection_IndexedDataMap::Iterator::Key");
|
||||
return myNode->Key1();
|
||||
}
|
||||
//! Performs comparison of two iterators.
|
||||
@@ -302,10 +291,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||
const TheKeyType& theKey1,
|
||||
const TheItemType& theItem)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theIndex < 1 || theIndex > Extent())
|
||||
Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::Substitute");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > Extent(), "NCollection_IndexedDataMap::Substitute");
|
||||
|
||||
IndexedDataMapNode * p;
|
||||
// check if theKey1 is not already in the map
|
||||
Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
|
||||
@@ -349,10 +336,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||
//! RemoveLast
|
||||
void RemoveLast (void)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (Extent() == 0)
|
||||
Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::RemoveLast");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (Extent() == 0, "NCollection_IndexedDataMap::RemoveLast");
|
||||
|
||||
IndexedDataMapNode * p, * q;
|
||||
// Find the node for the last index and remove it
|
||||
Standard_Integer iK2 = ::HashCode (Extent(), NbBuckets());
|
||||
@@ -389,10 +374,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||
//! FindKey
|
||||
const TheKeyType& FindKey (const Standard_Integer theKey2) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theKey2 < 1 || theKey2 > Extent())
|
||||
Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::FindKey");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theKey2 < 1 || theKey2 > Extent(), "NCollection_IndexedDataMap::FindKey");
|
||||
|
||||
IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
|
||||
if (aNode == NULL)
|
||||
{
|
||||
@@ -404,10 +387,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||
//! FindFromIndex
|
||||
const TheItemType& FindFromIndex (const Standard_Integer theKey2) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theKey2 < 1 || theKey2 > Extent())
|
||||
Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::FindFromIndex");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theKey2 < 1 || theKey2 > Extent(), "NCollection_IndexedDataMap::FindFromIndex");
|
||||
|
||||
IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
|
||||
if (aNode == NULL)
|
||||
{
|
||||
@@ -423,10 +404,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||
//! ChangeFromIndex
|
||||
TheItemType& ChangeFromIndex (const Standard_Integer theKey2)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theKey2 < 1 || theKey2 > Extent())
|
||||
Standard_OutOfRange::Raise("NCollection_IndexedDataMap::ChangeFromIndex");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theKey2 < 1 || theKey2 > Extent(), "NCollection_IndexedDataMap::ChangeFromIndex");
|
||||
|
||||
IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
|
||||
if (aNode == NULL)
|
||||
{
|
||||
@@ -457,10 +436,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||
//! FindFromKey
|
||||
const TheItemType& FindFromKey(const TheKeyType& theKey1) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (IsEmpty())
|
||||
Standard_NoSuchObject::Raise ("NCollection_IndexedDataMap::FindFromKey");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_IndexedDataMap::FindFromKey");
|
||||
|
||||
IndexedDataMapNode * pNode1 =
|
||||
(IndexedDataMapNode *) myData1[Hasher::HashCode(theKey1,NbBuckets())];
|
||||
while (pNode1)
|
||||
@@ -476,10 +453,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||
//! ChangeFromKey
|
||||
TheItemType& ChangeFromKey (const TheKeyType& theKey1)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (IsEmpty())
|
||||
Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::ChangeFromKey");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_IndexedDataMap::ChangeFromKey");
|
||||
|
||||
IndexedDataMapNode * pNode1 =
|
||||
(IndexedDataMapNode *) myData1[Hasher::HashCode(theKey1,NbBuckets())];
|
||||
while (pNode1)
|
||||
|
@@ -24,9 +24,7 @@
|
||||
|
||||
#include <NCollection_DefaultHasher.hxx>
|
||||
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Purpose: An indexed map is used to store keys and to bind
|
||||
@@ -53,10 +51,10 @@ class NCollection_IndexedMap : public NCollection_BaseMap
|
||||
const Standard_Integer theKey2,
|
||||
NCollection_ListNode* theNext1,
|
||||
NCollection_ListNode* theNext2) :
|
||||
NCollection_TListNode<TheKeyType> (theKey1, theNext1)
|
||||
NCollection_TListNode<TheKeyType> (theKey1, theNext1),
|
||||
myKey2(theKey2),
|
||||
myNext2((IndexedMapNode*)theNext2)
|
||||
{
|
||||
myKey2 = theKey2;
|
||||
myNext2 = (IndexedMapNode *) theNext2;
|
||||
}
|
||||
//! Key1
|
||||
TheKeyType& Key1 (void)
|
||||
@@ -103,10 +101,7 @@ class NCollection_IndexedMap : public NCollection_BaseMap
|
||||
//! Value access
|
||||
const TheKeyType& Value(void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise("NCollection_IndexedMap::Iterator::Value");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if(!More(), "NCollection_IndexedMap::Iterator::Value");
|
||||
return myMap->FindKey(myIndex);
|
||||
}
|
||||
//! Value change access denied - use Substitute
|
||||
@@ -267,10 +262,8 @@ class NCollection_IndexedMap : public NCollection_BaseMap
|
||||
void Substitute (const Standard_Integer theIndex,
|
||||
const TheKeyType& theKey1)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theIndex < 1 || theIndex > Extent())
|
||||
Standard_OutOfRange::Raise ("NCollection_IndexedMap::Substitute");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > Extent(), "NCollection_IndexedMap::Substitute");
|
||||
|
||||
IndexedMapNode * p;
|
||||
// check if theKey1 is not already in the map
|
||||
Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
|
||||
@@ -313,10 +306,8 @@ class NCollection_IndexedMap : public NCollection_BaseMap
|
||||
//! RemoveLast
|
||||
void RemoveLast (void)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (Extent() == 0)
|
||||
Standard_OutOfRange::Raise ("NCollection_IndexedMap::RemoveLast");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (Extent() == 0, "NCollection_IndexedMap::RemoveLast");
|
||||
|
||||
IndexedMapNode * p, * q;
|
||||
// Find the node for the last index and remove it
|
||||
Standard_Integer iK2 = ::HashCode (Extent(), NbBuckets());
|
||||
@@ -353,10 +344,8 @@ class NCollection_IndexedMap : public NCollection_BaseMap
|
||||
//! FindKey
|
||||
const TheKeyType& FindKey (const Standard_Integer theKey2) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theKey2 < 1 || theKey2 > Extent())
|
||||
Standard_OutOfRange::Raise ("NCollection_IndexedMap::FindKey");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theKey2 < 1 || theKey2 > Extent(), "NCollection_IndexedMap::FindKey");
|
||||
|
||||
IndexedMapNode * pNode2 =
|
||||
(IndexedMapNode *) myData2[::HashCode(theKey2,NbBuckets())];
|
||||
while (pNode2)
|
||||
|
@@ -19,9 +19,7 @@
|
||||
#include <NCollection_TListIterator.hxx>
|
||||
#include <NCollection_StlIterator.hxx>
|
||||
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Purpose: Simple list to link items together keeping the first
|
||||
@@ -102,23 +100,31 @@ public:
|
||||
//! First item
|
||||
const TheItemType& First (void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (IsEmpty())
|
||||
Standard_NoSuchObject::Raise ("NCollection_List::First");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_List::First");
|
||||
return ((const ListNode *) PFirst())->Value();
|
||||
}
|
||||
|
||||
//! First item (non-const)
|
||||
TheItemType& First (void)
|
||||
{
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_List::First");
|
||||
return ((ListNode *) PFirst())->ChangeValue();
|
||||
}
|
||||
|
||||
//! Last item
|
||||
const TheItemType& Last (void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (IsEmpty())
|
||||
Standard_NoSuchObject::Raise ("NCollection_List::Last");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_List::Last");
|
||||
return ((const ListNode *) PLast())->Value();
|
||||
}
|
||||
|
||||
//! Last item (non-const)
|
||||
TheItemType& Last (void)
|
||||
{
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_List::Last");
|
||||
return ((ListNode *) PLast())->ChangeValue();
|
||||
}
|
||||
|
||||
//! Append one item at the end
|
||||
TheItemType& Append (const TheItemType& theItem)
|
||||
{
|
||||
@@ -249,10 +255,8 @@ public:
|
||||
else
|
||||
{
|
||||
// No - this list has different memory scope
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!theIter.More())
|
||||
Standard_NoSuchObject::Raise ("NCollection_List::InsertAfter");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (!theIter.More(), "NCollection_List::InsertAfter");
|
||||
|
||||
Iterator anIter;
|
||||
anIter.myPrevious = theIter.myCurrent;
|
||||
anIter.myCurrent = theIter.myCurrent->Next();
|
||||
|
@@ -23,10 +23,7 @@
|
||||
#include <NCollection_DefaultHasher.hxx>
|
||||
|
||||
#include <Standard_ImmutableObject.hxx>
|
||||
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Purpose: Single hashed Map. This Map is used to store and
|
||||
@@ -96,10 +93,7 @@ class NCollection_Map : public NCollection_BaseMap
|
||||
//! Value inquiry
|
||||
const TheKeyType& Value(void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise ("NCollection_Map::Iterator::Value");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (!More(), "NCollection_Map::Iterator::Value");
|
||||
return ((MapNode *) myNode)->Value();
|
||||
}
|
||||
//! Value change access - denied
|
||||
@@ -109,12 +103,9 @@ class NCollection_Map : public NCollection_BaseMap
|
||||
return * (TheKeyType *) NULL; // For compiler
|
||||
}
|
||||
//! Key
|
||||
const TheKeyType& Key (void)
|
||||
const TheKeyType& Key (void) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (!More())
|
||||
Standard_NoSuchObject::Raise ("NCollection_Map::Iterator::Key");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (!More(), "NCollection_Map::Iterator::Key");
|
||||
return ((MapNode *) myNode)->Value();
|
||||
}
|
||||
};
|
||||
|
@@ -19,10 +19,8 @@
|
||||
#include <NCollection_BaseSequence.hxx>
|
||||
#include <NCollection_StlIterator.hxx>
|
||||
|
||||
#ifndef No_Exception
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Purpose: Definition of a sequence of elements indexed by
|
||||
@@ -252,10 +250,7 @@ public:
|
||||
void InsertAfter (const Standard_Integer theIndex,
|
||||
const TheItemType& theItem)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theIndex < 0 || theIndex > mySize)
|
||||
Standard_OutOfRange::Raise ("NCollection_Sequence::InsertAfter");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex > mySize, "NCollection_Sequence::InsertAfter");
|
||||
PInsertAfter (theIndex, new (this->myAllocator) Node (theItem));
|
||||
}
|
||||
|
||||
@@ -269,50 +264,36 @@ public:
|
||||
//! First item access
|
||||
const TheItemType& First () const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (mySize == 0)
|
||||
Standard_NoSuchObject::Raise ("NCollection_Sequence::First");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (mySize == 0, "NCollection_Sequence::First");
|
||||
return ((const Node *) myFirstItem) -> Value();
|
||||
}
|
||||
|
||||
//! First item access
|
||||
TheItemType& ChangeFirst()
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (mySize == 0)
|
||||
Standard_NoSuchObject::Raise ("NCollection_Sequence::ChangeFirst");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (mySize == 0, "NCollection_Sequence::ChangeFirst");
|
||||
return ((Node* )myFirstItem)->ChangeValue();
|
||||
}
|
||||
|
||||
//! Last item access
|
||||
const TheItemType& Last () const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (mySize == 0)
|
||||
Standard_NoSuchObject::Raise ("NCollection_Sequence::Last");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (mySize == 0, "NCollection_Sequence::Last");
|
||||
return ((const Node *) myLastItem) -> Value();
|
||||
}
|
||||
|
||||
//! Last item access
|
||||
TheItemType& ChangeLast()
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_NoSuchObject
|
||||
if (mySize == 0)
|
||||
Standard_NoSuchObject::Raise ("NCollection_Sequence::ChangeLast");
|
||||
#endif
|
||||
Standard_NoSuchObject_Raise_if (mySize == 0, "NCollection_Sequence::ChangeLast");
|
||||
return ((Node* )myLastItem)->ChangeValue();
|
||||
}
|
||||
|
||||
//! Constant item access by theIndex
|
||||
const TheItemType& Value (const Standard_Integer theIndex) const
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theIndex <= 0 || theIndex > mySize)
|
||||
Standard_OutOfRange::Raise ("NCollection_Sequence::Value");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theIndex <= 0 || theIndex > mySize, "NCollection_Sequence::Value");
|
||||
|
||||
NCollection_Sequence * const aLocalTHIS = (NCollection_Sequence *) this;
|
||||
aLocalTHIS -> myCurrentItem = Find (theIndex);
|
||||
aLocalTHIS -> myCurrentIndex = theIndex;
|
||||
@@ -326,10 +307,8 @@ public:
|
||||
//! Variable item access by theIndex
|
||||
TheItemType& ChangeValue (const Standard_Integer theIndex)
|
||||
{
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
if (theIndex <= 0 || theIndex > mySize)
|
||||
Standard_OutOfRange::Raise ("NCollection_Sequence::ChangeValue");
|
||||
#endif
|
||||
Standard_OutOfRange_Raise_if (theIndex <= 0 || theIndex > mySize, "NCollection_Sequence::ChangeValue");
|
||||
|
||||
myCurrentItem = Find (theIndex);
|
||||
myCurrentIndex = theIndex;
|
||||
return ((Node *) myCurrentItem) -> ChangeValue();
|
||||
|
@@ -43,10 +43,16 @@ template <class TheItemType> class NCollection_TListIterator
|
||||
myPrevious = myCurrent;
|
||||
myCurrent = myCurrent->Next();
|
||||
}
|
||||
|
||||
//! Constant Value access
|
||||
const TheItemType& Value (void) const
|
||||
{ return ((const NCollection_TListNode<TheItemType>*) myCurrent)->Value(); }
|
||||
//! Variable Value access
|
||||
|
||||
//! Non-const Value access
|
||||
TheItemType& Value (void)
|
||||
{ return ((NCollection_TListNode<TheItemType>*) myCurrent)->ChangeValue(); }
|
||||
|
||||
//! Non-const Value access
|
||||
TheItemType& ChangeValue (void) const
|
||||
{ return ((NCollection_TListNode<TheItemType> *)myCurrent)->ChangeValue(); }
|
||||
};
|
||||
|
@@ -29,7 +29,7 @@ template <class TheItemType> class NCollection_TListNode
|
||||
//! Constructor
|
||||
NCollection_TListNode (const TheItemType& theItem,
|
||||
NCollection_ListNode* theNext=NULL) :
|
||||
NCollection_ListNode (theNext) { myValue = theItem; }
|
||||
NCollection_ListNode (theNext), myValue(theItem) { }
|
||||
//! Constant value access
|
||||
const TheItemType& Value () const { return myValue; }
|
||||
//! Variable value access
|
||||
|
Reference in New Issue
Block a user