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.
#define _AIS_NDataMapOfTransientIteratorOfListTransient_HeaderFile
#include <AIS_NListIteratorOfListTransient.hxx>
-#include <NCollection_DefineDataMap.hxx>
+#include <NCollection_DataMap.hxx>
-DEFINE_BASECOLLECTION(AIS_BaseCollItListTransient,
- AIS_NListIteratorOfListTransient)
-DEFINE_DATAMAP (AIS_NDataMapOfTransientIteratorOfListTransient,
- AIS_BaseCollItListTransient,
- Handle(Standard_Transient),
- AIS_NListIteratorOfListTransient)
+typedef NCollection_DataMap<Handle(Standard_Transient), AIS_NListIteratorOfListTransient>
+ AIS_NDataMapOfTransientIteratorOfListTransient;
#endif
#define _AIS_NListTransient_HeaderFile
#include <Standard_Transient.hxx>
-#include <NCollection_StdBase.hxx>
-#include <NCollection_DefineList.hxx>
+#include <NCollection_List.hxx>
-DEFINE_LIST (AIS_NListTransient,
- NCollection_BaseCollTransient,
- Handle(Standard_Transient))
+typedef NCollection_List<Handle(Standard_Transient)> AIS_NListTransient;
#endif
#include <BOPAlgo_BuilderSolid.hxx>
#include <BRep_Tool.hxx>
-
+#include <NCollection_IncAllocator.hxx>
static
TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim);
public:
BOPCol_NCVector(const Standard_Integer theIncrement=256,
const Handle(NCollection_BaseAllocator)& theAlloc = NULL)
- : NCollection_Vector<Type>(theIncrement, theAlloc) {
- };
+ : NCollection_Vector<Type>(theIncrement, theAlloc)
+ {}
//
BOPCol_NCVector(const BOPCol_NCVector& theOther)
- : NCollection_Vector<Type>(theOther) {
- };
+ : NCollection_Vector<Type>(theOther)
+ {}
//
Type& Append1 ()
{
- Type& anAppended =
- *(Type* )NCollection_BaseVector::expandV (NCollection_BaseCollection<Type>::myAllocator,
- NCollection_Vector<Type>::myLength);
+ Type& anAppended = *(Type*)this->expandV (this->myLength);
return anAppended;
}
//
Standard_Integer Extent() const
{
- return NCollection_Vector<Type>::myLength;
+ return this->myLength;
}
- protected:
-
};
#endif
//
#include <Bnd_Box.hxx>
//
-#include <NCollection_BaseAllocator.hxx>
+#include <NCollection_IncAllocator.hxx>
#include <NCollection_UBTreeFiller.hxx>
//
#include <TopoDS_Shape.hxx>
#include <BRep_Tool.hxx>
#include <NCollection_UBTreeFiller.hxx>
+#include <NCollection_IncAllocator.hxx>
+
#include <BOPCol_BoxBndTree.hxx>
#include <BOPDS_IndexRange.hxx>
#include <BOPDS_PassKeyBoolean.hxx>
//
#include <Bnd_Box.hxx>
//
-#include <NCollection_BaseAllocator.hxx>
+#include <NCollection_IncAllocator.hxx>
#include <NCollection_UBTreeFiller.hxx>
//
#include <TopoDS.hxx>
#ifndef _Font_NListOfSystemFont_HeaderFile
#define _Font_NListOfSystemFont_HeaderFile
-#include <NCollection_DefineList.hxx>
+
+#include <NCollection_List.hxx>
#include <Font_SystemFont.hxx>
-DEFINE_LIST (Font_NListOfSystemFont,
- NCollection_List,
- Handle(Font_SystemFont))
+
+typedef NCollection_List<Handle(Font_SystemFont)> Font_NListOfSystemFont;
inline Standard_Boolean IsEqual (const Handle(Font_SystemFont)& theFirstFont,
const Handle(Font_SystemFont)& theSecondFont)
aNbListOfPointIndex=aListOfPointIndex.Extent();
if(aNbListOfPointIndex) {
nblines++;
- anArrayOfLines[nblines] = aListOfPointIndex;
+ anArrayOfLines[nblines].Assign (aListOfPointIndex);
anArrayOfLineType[nblines] = bIsPrevPointOnBoundary;
aListOfPointIndex.Clear();
}
#ifndef _Graphic3d_NListOfHAsciiString_HeaderFile
#define _Graphic3d_NListOfHAsciiString_HeaderFile
-#include <NCollection_DefineList.hxx>
+#include <NCollection_List.hxx>
#include <TCollection_HAsciiString.hxx>
-DEFINE_LIST (Graphic3d_NListOfHAsciiString,
- NCollection_List,
- Handle(TCollection_HAsciiString))
+typedef NCollection_List<Handle(TCollection_HAsciiString)> Graphic3d_NListOfHAsciiString;
#endif
#include <Message_MsgFile.hxx>
+#include <NCollection_DataMap.hxx>
+#include <OSD_Environment.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
-#include <NCollection_DefineBaseCollection.hxx>
-#include <NCollection_DefineDataMap.hxx>
-#include <OSD_Environment.hxx>
+
#include <stdlib.h>
#include <stdio.h>
-DEFINE_BASECOLLECTION(Message_CollectionOfExtendedString, TCollection_ExtendedString)
-DEFINE_DATAMAP(Message_DataMapOfExtendedString,
- Message_CollectionOfExtendedString,
- TCollection_AsciiString,
- TCollection_ExtendedString)
+typedef NCollection_DataMap<TCollection_AsciiString,TCollection_ExtendedString> Message_DataMapOfExtendedString;
static Message_DataMapOfExtendedString& msgsDataMap ()
{
NCollection_BaseMap.hxx
NCollection_BaseMap.cxx
-NCollection_BaseCollection.hxx
NCollection_TListNode.hxx
NCollection_TListIterator.hxx
NCollection_Sequence.hxx
NCollection_IndexedMap.hxx
NCollection_IndexedDataMap.hxx
-NCollection_DefineBaseCollection.hxx
-NCollection_DefineTListIterator.hxx
-NCollection_DefineTListNode.hxx
NCollection_DefineArray1.hxx
NCollection_DefineHArray1.hxx
NCollection_DefineArray2.hxx
NCollection_BaseVector.cxx
NCollection_Vector.hxx
NCollection_DefineVector.hxx
-NCollection_StdBase.hxx
NCollection_EBTree.hxx
NCollection_UBTree.hxx
#include <Standard_OutOfRange.hxx>
#endif
-#include <NCollection_BaseCollection.hxx>
+#include <NCollection_DefineAlloc.hxx>
#include <NCollection_StlIterator.hxx>
// *********************************************** Template for Array1 class
* compatibility the method IsAllocated remained in class along
* with IsDeletable.
*/
-template <class TheItemType> class NCollection_Array1
- : public NCollection_BaseCollection<TheItemType>
+template <class TheItemType>
+class NCollection_Array1
{
public:
//! STL-compliant typedef for value type
public:
//! Implementation of the Iterator interface.
- class Iterator : public NCollection_BaseCollection<TheItemType>::Iterator
+ class Iterator
{
public:
}
//! Check end
- virtual Standard_Boolean More (void) const
+ Standard_Boolean More (void) const
{ return myPtrCur < myPtrEnd; }
//! Increment operator
- virtual void Next (void)
+ void Next (void)
{ ++myPtrCur; }
//! Decrement operator
- virtual void Previous()
+ void Previous()
{ --myPtrCur; }
//! Offset operator.
- virtual void Offset (ptrdiff_t theOffset)
+ void Offset (ptrdiff_t theOffset)
{ myPtrCur += theOffset; }
//! Difference operator.
- virtual ptrdiff_t Differ (const Iterator& theOther) const
+ ptrdiff_t Differ (const Iterator& theOther) const
{ return myPtrCur - theOther.myPtrCur; }
//! Constant value access
- virtual const TheItemType& Value (void) const
+ const TheItemType& Value (void) const
{ return *myPtrCur; }
//! Variable value access
- virtual TheItemType& ChangeValue (void) const
+ TheItemType& ChangeValue (void) const
{ return *myPtrCur; }
//! Performs comparison of two iterators
- virtual Standard_Boolean IsEqual (const Iterator& theOther) const
+ Standard_Boolean IsEqual (const Iterator& theOther) const
{ return myPtrCur == theOther.myPtrCur; }
private:
//! Constructor
NCollection_Array1(const Standard_Integer theLower,
const Standard_Integer theUpper) :
- NCollection_BaseCollection<TheItemType> (),
myLowerBound (theLower),
myUpperBound (theUpper),
myDeletable (Standard_True)
//! Copy constructor
NCollection_Array1 (const NCollection_Array1& theOther) :
- NCollection_BaseCollection<TheItemType> (),
myLowerBound (theOther.Lower()),
myUpperBound (theOther.Upper()),
myDeletable (Standard_True)
NCollection_Array1 (const TheItemType& theBegin,
const Standard_Integer theLower,
const Standard_Integer theUpper) :
- NCollection_BaseCollection<TheItemType> (),
myLowerBound (theLower),
myUpperBound (theUpper),
myDeletable (Standard_False)
}
//! Size query
- virtual Standard_Integer Size (void) const
+ Standard_Integer Size (void) const
{ return Length(); }
//! Length query (the same)
Standard_Integer Length (void) const
Standard_Boolean IsAllocated (void) const
{ return myDeletable; }
- //! Assign (any collection to this array)
- // Copies items from the other collection into the allocated
- // 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)
+ //! Assignment
+ NCollection_Array1& Assign (const NCollection_Array1& theOther)
{
if (&theOther == this)
return *this;
return *this;
}
+ //! Assignment operator
+ NCollection_Array1& operator= (const NCollection_Array1& theOther)
+ {
+ return Assign (theOther);
+ }
+
//! @return first element
const TheItemType& First() const
{
~NCollection_Array1 (void)
{ 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 FIELDS -----------
Standard_Integer myLowerBound;
#include <Standard_OutOfRange.hxx>
#endif
-#include <NCollection_BaseCollection.hxx>
+#include <NCollection_DefineAlloc.hxx>
// *********************************************** Template for Array2 class
/**
* for (i = A.LowerRow(); i <= A.UpperRow(); i++)
* for (j = A.LowerCol(); j <= A.UpperCol(); j++)
*/
-template <class TheItemType> class NCollection_Array2
- : public NCollection_BaseCollection<TheItemType>
+template <class TheItemType>
+class NCollection_Array2
{
public:
//! STL-compliant typedef for value type
public:
// **************** Implementation of the Iterator interface.
- class Iterator : public NCollection_BaseCollection<TheItemType>::Iterator
+ class Iterator
{
public:
//! Empty constructor - for later Init
myArray = (NCollection_Array2 *) &theArray;
}
//! Check end
- virtual Standard_Boolean More (void) const
+ Standard_Boolean More (void) const
{ return (myCurrent < mySize); }
//! Make step
- virtual void Next (void)
+ void Next (void)
{ myCurrent++; }
//! Constant value access
- virtual const TheItemType& Value (void) const
+ const TheItemType& Value (void) const
{ return myArray->myStart[myCurrent]; }
//! Variable value access
- virtual TheItemType& ChangeValue (void) const
+ TheItemType& ChangeValue (void) const
{ return myArray->myStart[myCurrent]; }
private:
Standard_Integer myCurrent; //!< Index of the current item
const Standard_Integer theRowUpper,
const Standard_Integer theColLower,
const Standard_Integer theColUpper) :
- NCollection_BaseCollection<TheItemType> (),
myLowerRow (theRowLower),
myUpperRow (theRowUpper),
myLowerCol (theColLower),
//! Copy constructor
NCollection_Array2 (const NCollection_Array2& theOther) :
- NCollection_BaseCollection<TheItemType> (),
myLowerRow (theOther.LowerRow()),
myUpperRow (theOther.UpperRow()),
myLowerCol (theOther.LowerCol()),
const Standard_Integer theRowUpper,
const Standard_Integer theColLower,
const Standard_Integer theColUpper) :
- NCollection_BaseCollection<TheItemType> (),
myLowerRow (theRowLower),
myUpperRow (theRowUpper),
myLowerCol (theColLower),
}
//! Size (number of items)
- virtual Standard_Integer Size (void) const
+ Standard_Integer Size (void) const
{ return Length(); }
//! Length (number of items)
Standard_Integer Length (void) const
Standard_Boolean IsDeletable (void) const
{ return myDeletable; }
- //! Assign
- // Copies items from the other collection into the allocated
- // 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)
+ //! Assignment
+ NCollection_Array2& Assign (const NCollection_Array2& theOther)
{
if (&theOther == this)
return *this;
return *this;
}
+ //! Assignment operator
+ NCollection_Array2& operator= (const NCollection_Array2& theOther)
+ {
+ return Assign (theOther);
+ }
+
//! Constant value access
const TheItemType& Value (const Standard_Integer theRow,
const Standard_Integer theCol) const
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 FIELDS -----------
Standard_Integer myLowerRow;
// Purpose: Implementation of the BaseAllocator class
#include <NCollection_BaseAllocator.hxx>
+#include <NCollection_IncAllocator.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_Map.hxx>
#include <NCollection_List.hxx>
+++ /dev/null
-// 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
//purpose : Deletes all nodes from the list
//=======================================================================
-void NCollection_BaseList::PClear
- (NCollection_DelListNode fDel,
- Handle(NCollection_BaseAllocator)& theAllocator)
+void NCollection_BaseList::PClear (NCollection_DelListNode fDel)
{
NCollection_ListNode* pCur = myFirst;
NCollection_ListNode* pNext = NULL;
while(pCur)
{
pNext = pCur->Next();
- fDel (pCur,theAllocator);
+ fDel (pCur, myAllocator);
pCur = pNext;
}
myLength = 0;
//purpose :
//=======================================================================
-void NCollection_BaseList::PRemoveFirst
- (NCollection_DelListNode fDel,
- Handle(NCollection_BaseAllocator)& theAllocator)
+void NCollection_BaseList::PRemoveFirst (NCollection_DelListNode fDel)
{
Standard_NoSuchObject_Raise_if(IsEmpty(),
"NCollection_BaseList::PRemoveFirst");
NCollection_ListNode* pItem = myFirst;
myFirst = pItem->Next();
- fDel (pItem, theAllocator);
+ fDel (pItem, myAllocator);
myLength--;
if (myLength == 0)
myLast = NULL;
//purpose :
//=======================================================================
-void NCollection_BaseList::PRemove
- (Iterator& theIter,
- NCollection_DelListNode fDel,
- Handle(NCollection_BaseAllocator)& theAllocator)
+void NCollection_BaseList::PRemove (Iterator& theIter, NCollection_DelListNode fDel)
{
Standard_NoSuchObject_Raise_if(!theIter.More(),
"NCollection_BaseList::PRemove");
if (theIter.myPrevious == NULL)
{
- PRemoveFirst (fDel,theAllocator);
+ PRemoveFirst (fDel);
theIter.myCurrent = myFirst;
}
else
{
NCollection_ListNode* pNode = (theIter.myCurrent)->Next();
(theIter.myPrevious)->Next() = pNode;
- fDel (theIter.myCurrent,theAllocator);
+ fDel (theIter.myCurrent, myAllocator);
theIter.myCurrent = pNode;
if (pNode == NULL)
myLast = theIter.myPrevious;
#define NCollection_BaseList_HeaderFile
#include <Standard_NoSuchObject.hxx>
+#include <NCollection_DefineAlloc.hxx>
#include <NCollection_ListNode.hxx>
typedef void (* NCollection_DelListNode)
// ********************************************************** BaseList class
class NCollection_BaseList
{
- public:
+public:
+ //! Memory allocation
+ DEFINE_STANDARD_ALLOC
+ DEFINE_NCOLLECTION_ALLOC
+
+public:
class Iterator
{
public:
}
//-------------------------------------------------------
//! Performs comparison of two iterators
- virtual Standard_Boolean IsEqual (const Iterator& theOther) const
+ Standard_Boolean IsEqual (const Iterator& theOther) const
{
return *this == theOther;
}
// ******** Constructor
// Purpose: Initializes an empty list
- NCollection_BaseList(void) :
+ NCollection_BaseList (const Handle(NCollection_BaseAllocator)& theAllocator=0L) :
myFirst(NULL),
myLast(NULL),
- myLength(0) {}
+ myLength(0)
+ {
+ myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
+ }
// ******** PClear
// Purpose: deletes all nodes
- Standard_EXPORT void PClear (NCollection_DelListNode fDel,
- Handle(NCollection_BaseAllocator)& theAllocator);
+ Standard_EXPORT void PClear (NCollection_DelListNode fDel);
// ******** PFirst
// Purpose: Returns pointer to the first node
// ******** PRemoveFirst
// Purpose: Removes first node
Standard_EXPORT void PRemoveFirst
- (NCollection_DelListNode fDel,
- Handle(NCollection_BaseAllocator)& theAllocator);
+ (NCollection_DelListNode fDel);
// ******** PRemove
// Purpose: Removes the node pointed by theIter[ator]
Standard_EXPORT void PRemove
(Iterator& theIter,
- NCollection_DelListNode fDel,
- Handle(NCollection_BaseAllocator)& theAllocator);
+ NCollection_DelListNode fDel);
// ******** PInsertBefore
// Purpose: Inserts theNode before one pointed by theIter[ator]
Standard_EXPORT void PReverse ();
protected:
- // ------------ PRIVATE FIELDS ------------
+ // ------------ PROTECTED FIELDS ------------
+ Handle(NCollection_BaseAllocator) myAllocator;
NCollection_ListNode * myFirst; // Pointer to the head
NCollection_ListNode * myLast; // Pointer to the tail
Standard_Integer myLength; // Actual length
(const Standard_Integer NbBuckets,
Standard_Integer& N,
NCollection_ListNode**& data1,
- NCollection_ListNode**& data2,
- Handle(NCollection_BaseAllocator)& theAllocator) const
+ NCollection_ListNode**& data2) const
{
if (mySaturated) return Standard_False;
N = NextPrimeForMap(NbBuckets);
return Standard_False;
}
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 *));
if (isDouble)
{
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 *));
}
else
(const Standard_Integer NbBuckets,
const Standard_Integer N,
NCollection_ListNode** data1,
- NCollection_ListNode** data2,
- Handle(NCollection_BaseAllocator)& theAllocator)
+ NCollection_ListNode** data2)
{
if (myData1)
- theAllocator->Free(myData1);
+ myAllocator->Free(myData1);
if (myData2)
- theAllocator->Free(myData2);
+ myAllocator->Free(myData2);
myNbBuckets = N;
mySaturated = (myNbBuckets <= NbBuckets);
myData1 = data1;
//purpose :
//=======================================================================
-void NCollection_BaseMap::Destroy
- (NCollection_DelMapNode fDel,
- Handle(NCollection_BaseAllocator)& theAllocator,
- const Standard_Boolean doReleaseMemory)
+void NCollection_BaseMap::Destroy (NCollection_DelMapNode fDel,
+ Standard_Boolean doReleaseMemory)
{
if (!IsEmpty())
{
while (p)
{
q = (NCollection_ListNode*)p->Next();
- fDel (p, theAllocator);
+ fDel (p, myAllocator);
p = q;
}
data[i] = NULL;
{
mySaturated = Standard_False;
if (myData1)
- theAllocator->Free(myData1);
+ myAllocator->Free(myData1);
if (isDouble && myData2)
- theAllocator->Free(myData2);
+ myAllocator->Free(myData2);
myData1 = myData2 = NULL;
}
}
#ifndef NCollection_BaseMap_HeaderFile
#define NCollection_BaseMap_HeaderFile
-#include <Standard_Boolean.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_OStream.hxx>
-
#include <Standard.hxx>
-#include <Standard_Macro.hxx>
#include <NCollection_BaseAllocator.hxx>
+#include <NCollection_DefineAlloc.hxx>
#include <NCollection_ListNode.hxx>
typedef void (* NCollection_DelMapNode)
class NCollection_BaseMap
{
- public:
+public:
+ //! Memory allocation
+ DEFINE_STANDARD_ALLOC
+ DEFINE_NCOLLECTION_ALLOC
+
+public:
// **************************************** Class Iterator ****************
class Iterator
{
}
//! 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;
}
//! Constructor
NCollection_BaseMap (const Standard_Integer NbBuckets,
- const Standard_Boolean single) :
- myData1(NULL),
- myData2(NULL),
- isDouble(!single),
- mySaturated(Standard_False),
- myNbBuckets(NbBuckets),
- mySize(0) {}
+ const Standard_Boolean single,
+ const Handle(NCollection_BaseAllocator)& theAllocator)
+ : myData1(NULL),
+ myData2(NULL),
+ isDouble(!single),
+ mySaturated(Standard_False),
+ myNbBuckets(NbBuckets),
+ mySize(0)
+ {
+ myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
+ }
//! BeginResize
Standard_EXPORT Standard_Boolean BeginResize
(const Standard_Integer NbBuckets,
Standard_Integer& NewBuckets,
NCollection_ListNode**& data1,
- NCollection_ListNode**& data2,
- Handle(NCollection_BaseAllocator)& theAllocator) const;
+ NCollection_ListNode**& data2) const;
//! EndResize
Standard_EXPORT void EndResize
(const Standard_Integer NbBuckets,
const Standard_Integer NewBuckets,
NCollection_ListNode** data1,
- NCollection_ListNode** data2,
- Handle(NCollection_BaseAllocator)& theAllocator);
+ NCollection_ListNode** data2);
//! Resizable
Standard_Boolean Resizable() const
//! Destroy
Standard_EXPORT void Destroy(NCollection_DelMapNode fDel,
- Handle(NCollection_BaseAllocator)& theAllocator,
- const Standard_Boolean doReleaseMemory
- = Standard_True);
+ Standard_Boolean doReleaseMemory = Standard_True);
//! NextPrimeForMap
Standard_EXPORT Standard_Integer NextPrimeForMap
//! Exchange content of two maps without data copying
void exchangeMapsData (NCollection_BaseMap& theOther)
{
+ std::swap (myAllocator, theOther.myAllocator);
std::swap (myData1, theOther.myData1);
std::swap (myData2, theOther.myData2);
//std::swap (isDouble, theOther.isDouble);
protected:
// --------- PROTECTED FIELDS -----------
+ Handle(NCollection_BaseAllocator) myAllocator;
NCollection_ListNode ** myData1;
NCollection_ListNode ** myData2;
// ---------- FRIEND CLASSES ------------
friend class Iterator;
-
};
#endif
#include <Standard_OutOfRange.hxx>
#include <Standard_DomainError.hxx>
+inline void NCollection_BaseSequence::Nullify ()
+{
+ myFirstItem = myLastItem = myCurrentItem = NULL;
+ myCurrentIndex = mySize = 0;
+}
+
//=======================================================================
//function : ClearSeq
//purpose : removes all items from the current sequence
//=======================================================================
-void NCollection_BaseSequence::ClearSeq
- (NCollection_DelSeqNode fDel, Handle(NCollection_BaseAllocator)& theAl)
+void NCollection_BaseSequence::ClearSeq (NCollection_DelSeqNode fDel)
{
NCollection_SeqNode* p = myFirstItem;
while (p) {
NCollection_SeqNode* q = p;
p = p->Next();
- fDel (q, theAl);
+ fDel (q, myAllocator);
}
Nullify();
}
void NCollection_BaseSequence::RemoveSeq
(NCollection_BaseSequence::Iterator& thePosition,
- NCollection_DelSeqNode fDel,
- Handle(NCollection_BaseAllocator)& theAl)
+ NCollection_DelSeqNode fDel)
{
NCollection_SeqNode * aPos = thePosition.myCurrent;
if (aPos == NULL)
myCurrentItem = myLastItem;
myCurrentIndex = mySize;
- fDel (aPos, theAl);
+ fDel (aPos, myAllocator);
}
//=======================================================================
//purpose :
//=======================================================================
-void NCollection_BaseSequence::RemoveSeq
- (const Standard_Integer theIndex,
- NCollection_DelSeqNode fDel,
- Handle(NCollection_BaseAllocator)& theAl)
+void NCollection_BaseSequence::RemoveSeq (const Standard_Integer theIndex,
+ NCollection_DelSeqNode fDel)
{
Standard_OutOfRange_Raise_if (theIndex <= 0 || theIndex > mySize, "");
myCurrentIndex = mySize;
}
}
- fDel (p, theAl);
+ fDel (p, myAllocator);
}
//=======================================================================
//purpose : remove a set of items
//=======================================================================
-void NCollection_BaseSequence::RemoveSeq
- (const Standard_Integer From,
- const Standard_Integer To,
- NCollection_DelSeqNode fDel,
- Handle(NCollection_BaseAllocator)& theAl)
+void NCollection_BaseSequence::RemoveSeq (const Standard_Integer From,
+ const Standard_Integer To,
+ NCollection_DelSeqNode fDel)
{
Standard_OutOfRange_Raise_if (From <= 0 || To > mySize || From > To, "");
for (Standard_Integer i = From; i <= To; i++) {
NCollection_SeqNode * tmp = pfrom;
pfrom = pfrom->Next();
- fDel (tmp, theAl);
+ fDel (tmp, myAllocator);
}
}
#include <Standard.hxx>
#include <NCollection_BaseAllocator.hxx>
+#include <NCollection_DefineAlloc.hxx>
// **************************************** Class 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 * Next () const { return myNext; }
NCollection_SeqNode * Previous () const { return myPrevious; }
*/
class NCollection_BaseSequence
{
- public:
+public:
+ //! Memory allocation
+ DEFINE_STANDARD_ALLOC
+ DEFINE_NCOLLECTION_ALLOC
+
+public:
class Iterator
{
public:
protected:
// Methods PROTECTED
//
- inline NCollection_BaseSequence ();
- Standard_EXPORT void ClearSeq (NCollection_DelSeqNode fDel,
- Handle(NCollection_BaseAllocator)& theAl);
+ NCollection_BaseSequence (const Handle(NCollection_BaseAllocator)& theAllocator) :
+ myFirstItem (NULL),
+ 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_BaseSequence& S);
Standard_EXPORT void PPrepend (NCollection_SeqNode *);
Standard_EXPORT void PSplit (const Standard_Integer Index,
NCollection_BaseSequence& Sub);
Standard_EXPORT void RemoveSeq (Iterator& thePosition,
- NCollection_DelSeqNode fDel,
- Handle(NCollection_BaseAllocator)& theAl);
+ NCollection_DelSeqNode fDel);
Standard_EXPORT void RemoveSeq (const Standard_Integer Index,
- NCollection_DelSeqNode fDel,
- Handle(NCollection_BaseAllocator)& theAl);
+ NCollection_DelSeqNode fDel);
Standard_EXPORT void RemoveSeq (const Standard_Integer From,
const Standard_Integer To,
- NCollection_DelSeqNode fDel,
- Handle(NCollection_BaseAllocator)& theAl);
+ NCollection_DelSeqNode fDel);
Standard_EXPORT void PReverse ();
Standard_EXPORT void PExchange (const Standard_Integer I,
const Standard_Integer J) ;
protected:
// Fields PROTECTED
//
+ Handle(NCollection_BaseAllocator) myAllocator;
NCollection_SeqNode* myFirstItem;
NCollection_SeqNode* myLastItem;
NCollection_SeqNode* myCurrentItem;
//
Standard_EXPORT NCollection_BaseSequence
(const NCollection_BaseSequence& Other);
- inline void Nullify ();
+ inline void Nullify ();
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
//=======================================================================
NCollection_BaseVector::MemBlock* NCollection_BaseVector
- ::allocMemBlocks (Handle(NCollection_BaseAllocator)& theAllocator,
- const Standard_Integer theCapacity,
+ ::allocMemBlocks (const Standard_Integer theCapacity,
MemBlock* theSource,
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
Standard_Integer aCapacity = 0;
{
memcpy (aData, theSource, theSourceSize * sizeof(MemBlock));
aCapacity = theSourceSize;
- theAllocator->Free (theSource);
+ myAllocator->Free (theSource);
}
// Nullify newly allocated blocks
//purpose : returns the pointer where the new data item is supposed to be put
//=======================================================================
-void* NCollection_BaseVector::expandV (Handle(NCollection_BaseAllocator)& theAllocator,
- const Standard_Integer theIndex)
+void* NCollection_BaseVector::expandV (const Standard_Integer theIndex)
{
const Standard_Integer aNewLength = theIndex + 1;
if (myNBlocks > 0)
// Reallocate the array myData
do myCapacity += GetCapacity(myIncrement); while (myCapacity <= nNewBlock);
- myData = allocMemBlocks (theAllocator, myCapacity, myData, myNBlocks);
+ myData = allocMemBlocks (myCapacity, myData, myNBlocks);
}
if (myNBlocks > 0)
{
#define NCollection_BaseVector_HeaderFile
#include <Standard_TypeDef.hxx>
-#include <NCollection_BaseAllocator.hxx>
-#include <stddef.h>
-
#include <Standard_OutOfRange.hxx>
+#include <NCollection_BaseAllocator.hxx>
+#include <NCollection_DefineAlloc.hxx>
-#if defined(_MSC_VER)
- #pragma warning(push, 1)
- #pragma warning(disable:4355)
-#endif
+#include <stddef.h>
// this value defines the number of blocks that are reserved
// when the capacity of vector is increased
//! Class NCollection_BaseVector - base for NCollection_Vector template
class NCollection_BaseVector
{
+public:
+ //! Memory allocation
+ DEFINE_STANDARD_ALLOC
+ DEFINE_NCOLLECTION_ALLOC
protected:
}
}
- virtual void offsetV (Standard_Integer theOffset)
+ void offsetV (Standard_Integer theOffset)
{
const Standard_Integer anIndex = myCurIndex + myICurBlock * myVector->myIncrement + theOffset;
myICurBlock = 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;
}
const Standard_Integer theSize);
//! Allocate memory for array of memory blocks.
- //! @param theAllocator Memory allocator to use
//! @param theCapacity Number of memory blocks in array
//! @param theSource Original array of memory blocks, will be automatically deallocated
//! @param theSourceSize Number of memory blocks in original array
- Standard_EXPORT static MemBlock* allocMemBlocks (Handle(NCollection_BaseAllocator)& theAllocator,
- const Standard_Integer theCapacity,
- MemBlock* theSource = NULL,
- const Standard_Integer theSourceSize = 0);
+ Standard_EXPORT MemBlock* allocMemBlocks (const Standard_Integer theCapacity,
+ MemBlock* theSource = NULL,
+ const Standard_Integer theSourceSize = 0);
protected: //! @name protected methods
//! Empty constructor
- NCollection_BaseVector (Handle(NCollection_BaseAllocator)& theAllocator,
+ NCollection_BaseVector (const Handle(NCollection_BaseAllocator)& theAllocator,
initMemBlocks_t theInitBlocks,
const size_t theSize,
const Standard_Integer theInc)
myLength (0),
myCapacity (GetCapacity (myIncrement)),
myNBlocks (0),
- myData (allocMemBlocks (theAllocator, myCapacity)),
- myInitBlocks (theInitBlocks) {}
+ myInitBlocks (theInitBlocks)
+ {
+ myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
+ myData = allocMemBlocks (myCapacity);
+ }
//! Copy constructor
- NCollection_BaseVector (Handle(NCollection_BaseAllocator)& theAllocator,
+ NCollection_BaseVector (const Handle(NCollection_BaseAllocator)& theAllocator,
initMemBlocks_t theInitBlocks,
const NCollection_BaseVector& theOther)
: myItemSize (theOther.myItemSize),
myLength (theOther.myLength),
myCapacity (GetCapacity(myIncrement) + theOther.myLength / 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
- Standard_EXPORT void* expandV (Handle(NCollection_BaseAllocator)& theAllocator,
- const Standard_Integer theIndex);
+ Standard_EXPORT void* expandV (const Standard_Integer theIndex);
//! Locate the memory holding the desired value
inline void* findV (const Standard_Integer theIndex) const
//! Empty the vector of its objects
Standard_EXPORT void Clear();
-protected: //! @name Private fields
+protected: //! @name Protected fields
+ Handle(NCollection_BaseAllocator) myAllocator;
size_t myItemSize;
Standard_Integer myIncrement;
Standard_Integer myLength;
protected:
friend class Iterator;
-
};
-#if defined(_MSC_VER)
- #pragma warning(pop)
-#endif
-
#endif // NCollection_BaseVector_HeaderFile
}
//! Destructor.
- virtual ~NCollection_Buffer()
+ ~NCollection_Buffer()
{
Free();
}
#include <NCollection_List.hxx>
#include <NCollection_Map.hxx>
#include <NCollection_DataMap.hxx>
-#include <NCollection_BaseAllocator.hxx>
+#include <NCollection_IncAllocator.hxx>
#include <NCollection_TypeDef.hxx>
//! Auxiliary enumeration serving as responce from method Inspect
#ifndef NCollection_DataMap_HeaderFile
#define NCollection_DataMap_HeaderFile
-#include <NCollection_BaseCollection.hxx>
#include <NCollection_BaseMap.hxx>
#include <NCollection_TListNode.hxx>
#include <NCollection_StlIterator.hxx>
template < class TheKeyType,
class TheItemType,
- class Hasher = NCollection_DefaultHasher<TheKeyType> > class NCollection_DataMap
-
- : public NCollection_BaseCollection<TheItemType>,
- public NCollection_BaseMap
+ class Hasher = NCollection_DefaultHasher<TheKeyType> >
+class NCollection_DataMap : public NCollection_BaseMap
{
// **************** Adaptation of the TListNode to the DATAmap
public:
const TheKeyType& Key (void) const
{ return myKey; }
- //! Static deleter to be passed to BaseList
+ //! Static deleter to be passed to BaseMap
static void delNode (NCollection_ListNode * theNode,
Handle(NCollection_BaseAllocator)& theAl)
{
public:
// **************** Implementation of the Iterator interface.
- class Iterator
- : public NCollection_BaseCollection<TheItemType>::Iterator,
- public NCollection_BaseMap::Iterator
+ class Iterator : public NCollection_BaseMap::Iterator
{
public:
//! Empty constructor
Iterator (const NCollection_DataMap& theMap) :
NCollection_BaseMap::Iterator(theMap) {}
//! Query if the end of collection is reached by iterator
- virtual Standard_Boolean More(void) const
+ Standard_Boolean More(void) const
{ return PMore(); }
//! Make a step along the collection
- virtual void Next(void)
+ void Next(void)
{ PNext(); }
//! Value inquiry
- virtual const TheItemType& Value(void) const
+ const TheItemType& Value(void) const
{
#if !defined No_Exception && !defined No_Standard_NoSuchObject
if (!More())
return ((DataMapNode *) myNode)->Value();
}
//! Value change access
- virtual TheItemType& ChangeValue(void) const
+ TheItemType& ChangeValue(void) const
{
#if !defined No_Exception && !defined No_Standard_NoSuchObject
if (!More())
//! Constructor
NCollection_DataMap (const Standard_Integer NbBuckets=1,
const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
- : NCollection_BaseCollection<TheItemType>(theAllocator),
- NCollection_BaseMap (NbBuckets, Standard_True) {}
+ : NCollection_BaseMap (NbBuckets, Standard_True, theAllocator) {}
//! Copy constructor
NCollection_DataMap (const NCollection_DataMap& theOther)
- : NCollection_BaseCollection<TheItemType>(theOther.myAllocator),
- NCollection_BaseMap (theOther.NbBuckets(), Standard_True)
+ : NCollection_BaseMap (theOther.NbBuckets(), Standard_True, theOther.myAllocator)
{ *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.
//! Notice that allocators will be swapped as well!
void Exchange (NCollection_DataMap& theOther)
{
- this->exchangeAllocators (theOther);
- this->exchangeMapsData (theOther);
+ this->exchangeMapsData (theOther);
}
- //! = another map
- NCollection_DataMap& operator= (const NCollection_DataMap& theOther)
+ //! Assignment
+ NCollection_DataMap& Assign (const NCollection_DataMap& theOther)
{
if (this == &theOther)
return *this;
return *this;
}
+ //! Assignment operator
+ NCollection_DataMap& operator= (const NCollection_DataMap& theOther)
+ {
+ return Assign (theOther);
+ }
+
//! ReSize
void ReSize (const Standard_Integer N)
{
NCollection_ListNode** newdata = NULL;
NCollection_ListNode** dummy = NULL;
Standard_Integer newBuck;
- if (BeginResize (N, newBuck, newdata, dummy, this->myAllocator))
+ if (BeginResize (N, newBuck, newdata, dummy))
{
if (myData1)
{
}
}
}
- EndResize (N, newBuck, newdata, dummy, this->myAllocator);
+ EndResize (N, newBuck, newdata, dummy);
}
}
//! Clear data. If doReleaseMemory is false then the table of
//! buckets is not released and will be reused.
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
- { Destroy (DataMapNode::delNode, this->myAllocator, doReleaseMemory); }
+ { Destroy (DataMapNode::delNode, doReleaseMemory); }
//! Clear data and reset allocator
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
{ Clear(); }
//! Size
- virtual Standard_Integer Size(void) const
+ Standard_Integer Size(void) const
{ 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
#ifndef NCollection_DefineArray1_HeaderFile
#define NCollection_DefineArray1_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
#include <NCollection_Array1.hxx>
// *********************************************** Template for Array1 class
#ifndef NCollection_DefineArray2_HeaderFile
#define NCollection_DefineArray2_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
#include <NCollection_Array2.hxx>
// *********************************************** Template for Array2 class
+++ /dev/null
-// 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
#ifndef NCollection_DefineDataMap_HeaderFile
#define NCollection_DefineDataMap_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
#include <NCollection_DataMap.hxx>
// *********************************************** Class DataMap *************
#ifndef NCollection_DefineDoubleMap_HeaderFile
#define NCollection_DefineDoubleMap_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
#include <NCollection_DoubleMap.hxx>
// *********************************************** Class DoubleMap ************
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_&); \
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, \
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; \
#ifndef NCollection_DefineIndexedDataMap_HeaderFile
#define NCollection_DefineIndexedDataMap_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
#include <NCollection_IndexedDataMap.hxx>
// *********************************************** Class IndexedDataMap ******
#ifndef NCollection_DefineIndexedMap_HeaderFile
#define NCollection_DefineIndexedMap_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
#include <NCollection_IndexedMap.hxx>
// *********************************************** Class IndexedMap ***********
#ifndef NCollection_DefineMap_HeaderFile
#define NCollection_DefineMap_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
#include <NCollection_Map.hxx>
// *********************************************** Class Map *****************
#ifndef NCollection_DefineSequence_HeaderFile
#define NCollection_DefineSequence_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
#include <NCollection_Sequence.hxx>
// **************************************** Template for Sequence class ********
+++ /dev/null
-// 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
+++ /dev/null
-// 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
#ifndef NCollection_DefineVector_HeaderFile
#define NCollection_DefineVector_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
#include <NCollection_Vector.hxx>
// Class NCollection_Vector (dynamic array of objects)
#define NCollection_DoubleMap_HeaderFile
#include <NCollection_TypeDef.hxx>
-#include <NCollection_BaseCollection.hxx>
#include <NCollection_BaseMap.hxx>
#include <NCollection_TListNode.hxx>
#include <Standard_TypeMismatch.hxx>
template < class TheKey1Type,
class TheKey2Type,
class Hasher1 = NCollection_DefaultHasher<TheKey1Type>,
- class Hasher2 = NCollection_DefaultHasher<TheKey2Type> > class NCollection_DoubleMap
- : public NCollection_BaseCollection<TheKey2Type>,
- public NCollection_BaseMap
+ class Hasher2 = NCollection_DefaultHasher<TheKey2Type> >
+class NCollection_DoubleMap : public NCollection_BaseMap
{
// **************** Adaptation of the TListNode to the DOUBLEmap
public:
public:
// **************** Implementation of the Iterator interface.
- class Iterator
- : public NCollection_BaseCollection<TheKey2Type>::Iterator,
- public NCollection_BaseMap::Iterator
+ class Iterator : public NCollection_BaseMap::Iterator
{
public:
//! Empty constructor
- Iterator (void) :
- NCollection_BaseMap::Iterator() {}
+ Iterator (void) {}
//! Constructor
Iterator (const NCollection_DoubleMap& theMap) :
NCollection_BaseMap::Iterator(theMap) {}
//! Query if the end of collection is reached by iterator
- virtual Standard_Boolean More(void) const
+ Standard_Boolean More(void) const
{ return PMore(); }
//! Make a step along the collection
- virtual void Next(void)
+ void Next(void)
{ PNext(); }
//! Key1 inquiry
const TheKey1Type& Key1(void) const
return ((DoubleMapNode *) myNode)->Key2();
}
//! Value access
- virtual const TheKey2Type& Value(void) const
+ const TheKey2Type& Value(void) const
{
#if !defined No_Exception && !defined No_Standard_NoSuchObject
if (!More())
return ((DoubleMapNode *) myNode)->Value();
}
//! Value change access - denied
- virtual TheKey2Type& ChangeValue(void) const
+ TheKey2Type& ChangeValue(void) const
{
Standard_ImmutableObject::Raise("NCollection_DoubleMap::Iterator::ChangeValue");
return * (TheKey2Type *) NULL; // For compiler
//! Constructor
NCollection_DoubleMap (const Standard_Integer NbBuckets=1,
const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
- : NCollection_BaseCollection<TheKey2Type>(theAllocator),
- NCollection_BaseMap (NbBuckets, Standard_False) {}
+ : NCollection_BaseMap (NbBuckets, Standard_False, theAllocator) {}
//! Copy constructor
NCollection_DoubleMap (const NCollection_DoubleMap& theOther)
- : NCollection_BaseCollection<TheKey2Type>(theOther.myAllocator),
- NCollection_BaseMap (theOther.NbBuckets(), Standard_False)
+ : NCollection_BaseMap (theOther.NbBuckets(), Standard_False, theOther.myAllocator)
{ *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.
//! Notice that allocators will be swapped as well!
void Exchange (NCollection_DoubleMap& theOther)
{
- this->exchangeAllocators (theOther);
- this->exchangeMapsData (theOther);
+ this->exchangeMapsData (theOther);
}
- //! = another map
- NCollection_DoubleMap& operator=(const NCollection_DoubleMap& theOther)
+ //! Assignment
+ NCollection_DoubleMap& Assign (const NCollection_DoubleMap& theOther)
{
if (this == &theOther)
return *this;
return *this;
}
+ //! Assignment operator
+ NCollection_DoubleMap& operator= (const NCollection_DoubleMap& theOther)
+ {
+ return Assign (theOther);
+ }
+
//! ReSize
void ReSize (const Standard_Integer N)
{
NCollection_ListNode** ppNewData1 = NULL;
NCollection_ListNode** ppNewData2 = NULL;
Standard_Integer newBuck;
- if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator))
+ if (BeginResize (N, newBuck, ppNewData1, ppNewData2))
{
if (myData1)
{
}
}
}
- EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
+ EndResize (N, newBuck, ppNewData1, ppNewData2);
}
}
//! Clear data. If doReleaseMemory is false then the table of
//! buckets is not released and will be reused.
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
- { Destroy (DoubleMapNode::delNode, this->myAllocator, doReleaseMemory); }
+ { Destroy (DoubleMapNode::delNode, doReleaseMemory); }
//! Clear data and reset allocator
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
{ Clear(); }
//! Size
- virtual Standard_Integer Size(void) const
+ Standard_Integer Size(void) const
{ 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
#ifndef NCollection_IndexedDataMap_HeaderFile
#define NCollection_IndexedDataMap_HeaderFile
-#include <NCollection_BaseCollection.hxx>
#include <NCollection_BaseMap.hxx>
#include <NCollection_TListNode.hxx>
#include <Standard_TypeMismatch.hxx>
template < class TheKeyType,
class TheItemType,
class Hasher = NCollection_DefaultHasher<TheKeyType> >
- class NCollection_IndexedDataMap
- : public NCollection_BaseCollection<TheItemType>,
- public NCollection_BaseMap
+class NCollection_IndexedDataMap : public NCollection_BaseMap
{
//! Adaptation of the TListNode to the INDEXEDDatamap
private:
public:
//! Implementation of the Iterator interface.
- class Iterator : public NCollection_BaseCollection<TheItemType>::Iterator
+ class Iterator
{
public:
//! Empty constructor
myNode (myMap->nodeFromIndex (1)),
myIndex (1) {}
//! 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()); }
//! Make a step along the collection
- virtual void Next(void)
+ void Next(void)
{
myNode = myMap->nodeFromIndex (++myIndex);
}
//! Value access
- virtual const TheItemType& Value(void) const
+ const TheItemType& Value(void) const
{
#if !defined No_Exception && !defined No_Standard_NoSuchObject
if (!More())
return myNode->Value();
}
//! ChangeValue access
- virtual TheItemType& ChangeValue(void) const
+ TheItemType& ChangeValue(void) const
{
#if !defined No_Exception && !defined No_Standard_NoSuchObject
if (!More())
return myNode->Key1();
}
//! Performs comparison of two iterators.
- virtual Standard_Boolean IsEqual (const Iterator& theOther) const
+ Standard_Boolean IsEqual (const Iterator& theOther) const
{
return myMap == theOther.myMap &&
myNode == theOther.myNode &&
//! Constructor
NCollection_IndexedDataMap (const Standard_Integer NbBuckets=1,
const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
- : NCollection_BaseCollection<TheItemType>(theAllocator),
- NCollection_BaseMap (NbBuckets, Standard_False) {}
+ : NCollection_BaseMap (NbBuckets, Standard_False, theAllocator) {}
//! Copy constructor
NCollection_IndexedDataMap (const NCollection_IndexedDataMap& theOther)
- : NCollection_BaseCollection<TheItemType>(theOther.myAllocator),
- NCollection_BaseMap (theOther.NbBuckets(), Standard_False)
+ : NCollection_BaseMap (theOther.NbBuckets(), Standard_False, theOther.myAllocator)
{ *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.
//! Notice that allocators will be swapped as well!
void Exchange (NCollection_IndexedDataMap& theOther)
{
- this->exchangeAllocators (theOther);
- this->exchangeMapsData (theOther);
+ this->exchangeMapsData (theOther);
}
- //! = another map
- NCollection_IndexedDataMap& operator=
- (const NCollection_IndexedDataMap& theOther)
+ //! Assignment
+ NCollection_IndexedDataMap& Assign (const NCollection_IndexedDataMap& theOther)
{
if (this == &theOther)
return *this;
return *this;
}
+ //! Assignment operator
+ NCollection_IndexedDataMap& operator= (const NCollection_IndexedDataMap& theOther)
+ {
+ return Assign (theOther);
+ }
+
//! ReSize
void ReSize (const Standard_Integer N)
{
NCollection_ListNode** ppNewData1 = NULL;
NCollection_ListNode** ppNewData2 = NULL;
Standard_Integer newBuck;
- if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator))
+ if (BeginResize (N, newBuck, ppNewData1, ppNewData2))
{
if (myData1)
{
}
}
}
- EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
+ EndResize (N, newBuck, ppNewData1, ppNewData2);
}
}
//! Clear data. If doReleaseMemory is false then the table of
//! buckets is not released and will be reused.
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
- { Destroy (IndexedDataMapNode::delNode, this->myAllocator, doReleaseMemory); }
+ { Destroy (IndexedDataMapNode::delNode, doReleaseMemory); }
//! Clear data and reset allocator
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
{ Clear(); }
//! Size
- virtual Standard_Integer Size(void) const
+ Standard_Integer Size(void) const
{ 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)); }
-
//! Find map node associated with specified index.
//! Return NULL if not found (exception-free internal implementation).
IndexedDataMapNode* nodeFromIndex (const Standard_Integer theKey2) const
#ifndef NCollection_IndexedMap_HeaderFile
#define NCollection_IndexedMap_HeaderFile
-#include <NCollection_BaseCollection.hxx>
#include <NCollection_BaseMap.hxx>
#include <NCollection_TListNode.hxx>
#include <NCollection_StlIterator.hxx>
template < class TheKeyType,
class Hasher = NCollection_DefaultHasher<TheKeyType> >
- class NCollection_IndexedMap
- : public NCollection_BaseCollection<TheKeyType>,
- public NCollection_BaseMap
+class NCollection_IndexedMap : public NCollection_BaseMap
{
// **************** Adaptation of the TListNode to the INDEXEDmap
private:
public:
// **************** Implementation of the Iterator interface.
- class Iterator
- : public NCollection_BaseCollection<TheKeyType>::Iterator
+ class Iterator
{
public:
//! Empty constructor
myMap((NCollection_IndexedMap *) &theMap),
myIndex(1) {}
//! 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()); }
//! Make a step along the collection
- virtual void Next(void)
+ void Next(void)
{ myIndex++; }
//! Value access
- virtual const TheKeyType& Value(void) const
+ const TheKeyType& Value(void) const
{
#if !defined No_Exception && !defined No_Standard_NoSuchObject
if (!More())
return myMap->FindKey(myIndex);
}
//! Value change access denied - use Substitute
- virtual TheKeyType& ChangeValue(void) const
+ TheKeyType& ChangeValue(void) const
{
Standard_ImmutableObject::Raise ("impossible to ChangeValue");
return * (TheKeyType *) NULL; // This for compiler
}
//! 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;
}
//! Constructor
NCollection_IndexedMap (const Standard_Integer NbBuckets=1,
- const Handle(NCollection_BaseAllocator)& theAllocator=0L) :
- NCollection_BaseCollection<TheKeyType>(theAllocator),
- NCollection_BaseMap (NbBuckets, Standard_False) {}
+ const Handle(NCollection_BaseAllocator)& theAllocator=0L)
+ : NCollection_BaseMap (NbBuckets, Standard_False, theAllocator) {}
//! Copy constructor
- NCollection_IndexedMap (const NCollection_IndexedMap& theOther) :
- NCollection_BaseCollection<TheKeyType>(theOther.myAllocator),
- NCollection_BaseMap (theOther.NbBuckets(), Standard_False)
+ NCollection_IndexedMap (const NCollection_IndexedMap& theOther)
+ : NCollection_BaseMap (theOther.NbBuckets(), Standard_False, theOther.myAllocator)
{ *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.
//! Notice that allocators will be swapped as well!
void Exchange (NCollection_IndexedMap& theOther)
{
- this->exchangeAllocators (theOther);
- this->exchangeMapsData (theOther);
+ this->exchangeMapsData (theOther);
}
- //! = another map
- NCollection_IndexedMap& operator= (const NCollection_IndexedMap& theOther)
+ //! Assign
+ NCollection_IndexedMap& Assign (const NCollection_IndexedMap& theOther)
{
if (this == &theOther)
return *this;
return *this;
}
+ //! Assignment operator
+ NCollection_IndexedMap& operator= (const NCollection_IndexedMap& theOther)
+ {
+ return Assign (theOther);
+ }
+
//! ReSize
void ReSize (const Standard_Integer N)
{
NCollection_ListNode** ppNewData1 = NULL;
NCollection_ListNode** ppNewData2 = NULL;
Standard_Integer newBuck;
- if (BeginResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator))
+ if (BeginResize (N, newBuck, ppNewData1, ppNewData2))
{
if (myData1)
{
}
}
}
- EndResize (N, newBuck, ppNewData1, ppNewData2, this->myAllocator);
+ EndResize (N, newBuck, ppNewData1, ppNewData2);
}
}
//! Clear data. If doReleaseMemory is false then the table of
//! buckets is not released and will be reused.
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
- { Destroy (IndexedMapNode::delNode, this->myAllocator, doReleaseMemory); }
+ { Destroy (IndexedMapNode::delNode, doReleaseMemory); }
//! Clear data and reset allocator
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
{ Clear(); }
//! Size
- virtual Standard_Integer Size(void) const
+ Standard_Integer Size(void) const
{ 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
* and the last one.
* Inherits BaseList, adding the data item to each node.
*/
-template <class TheItemType> class NCollection_List
- : public NCollection_BaseCollection<TheItemType>,
- public NCollection_BaseList
+template <class TheItemType>
+class NCollection_List : public NCollection_BaseList
{
public:
//! STL-compliant typedef for value type
//! Constructor
NCollection_List(const Handle(NCollection_BaseAllocator)& theAllocator=0L) :
- NCollection_BaseCollection<TheItemType>(theAllocator),
- NCollection_BaseList() {}
+ NCollection_BaseList(theAllocator) {}
//! Copy constructor
NCollection_List (const NCollection_List& theOther) :
- NCollection_BaseCollection<TheItemType>(theOther.myAllocator),
- NCollection_BaseList()
- { *this = theOther; }
+ NCollection_BaseList(theOther.myAllocator)
+ {
+ Assign (theOther);
+ }
//! Size - Number of items
- virtual Standard_Integer Size (void) const
+ Standard_Integer Size (void) const
{ 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)
void Assign (const NCollection_List& theOther)
{
if (this != &theOther) {
- Clear();
+ Clear(theOther.myAllocator);
appendList(theOther.PFirst());
}
}
- //! Replace this list by the items of theOther list
+ //! Replacement operator
NCollection_List& operator= (const NCollection_List& theOther)
- {
- if (this != &theOther) {
- Clear (theOther.myAllocator);
- appendList(theOther.PFirst());
- }
+ {
+ Assign (theOther);
return *this;
}
//! Clear this list
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator=0L)
{
- PClear (ListNode::delNode, this->myAllocator);
+ PClear (ListNode::delNode);
if (!theAllocator.IsNull())
this->myAllocator = theAllocator;
}
//! RemoveFirst item
void RemoveFirst (void)
- { PRemoveFirst (ListNode::delNode, this->myAllocator); }
+ { PRemoveFirst (ListNode::delNode); }
//! Remove item
void Remove (Iterator& theIter)
{
- PRemove (theIter, ListNode::delNode, this->myAllocator);
+ PRemove (theIter, ListNode::delNode);
}
//! InsertBefore
private:
// ----------- 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
void appendList(const NCollection_ListNode * pCur) {
while (pCur) {
#define NCollection_ListNode_HeaderFile
#include <NCollection_BaseAllocator.hxx>
+#include <NCollection_DefineAlloc.hxx>
/**
* Purpose: This class is used to represent a node in the BaseList and
*/
class NCollection_ListNode
{
- public:
+public:
+ // define new operator for use with NCollection allocators
+ DEFINE_NCOLLECTION_ALLOC
+public:
//! The only constructor
NCollection_ListNode (NCollection_ListNode* theNext)
{ myNext = theNext; }
private:
//! operator= - forbidden
- NCollection_ListNode& operator=(const NCollection_ListNode& )
- {return *this;}
+ NCollection_ListNode& operator= (const NCollection_ListNode&);
+
//! copy constructor - forbidden
- NCollection_ListNode (const NCollection_ListNode& ) {}
+ NCollection_ListNode (const NCollection_ListNode&);
private:
NCollection_ListNode * myNext; //!< Pointer to the next node
NCollection_LocalArray ()
: myPtr (myBuffer) {}
- virtual ~NCollection_LocalArray()
+ ~NCollection_LocalArray()
{
Deallocate();
}
#ifndef NCollection_Map_HeaderFile
#define NCollection_Map_HeaderFile
-#include <NCollection_BaseCollection.hxx>
#include <NCollection_BaseMap.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_TListNode.hxx>
*/
template < class TheKeyType,
- class Hasher = NCollection_DefaultHasher<TheKeyType> > class NCollection_Map
- : public NCollection_BaseCollection<TheKeyType>,
- public NCollection_BaseMap
+ class Hasher = NCollection_DefaultHasher<TheKeyType> >
+class NCollection_Map : public NCollection_BaseMap
{
//! Adaptation of the TListNode to the map notations
public:
public:
//! Implementation of the Iterator interface.
- class Iterator
- : public NCollection_BaseCollection<TheKeyType>::Iterator,
- public NCollection_BaseMap::Iterator
+ class Iterator : public NCollection_BaseMap::Iterator
{
public:
//! Empty constructor
Iterator (const NCollection_Map& theMap) :
NCollection_BaseMap::Iterator(theMap) {}
//! Query if the end of collection is reached by iterator
- virtual Standard_Boolean More(void) const
+ Standard_Boolean More(void) const
{ return PMore(); }
//! Make a step along the collection
- virtual void Next(void)
+ void Next(void)
{ PNext(); }
//! Value inquiry
- virtual const TheKeyType& Value(void) const
+ const TheKeyType& Value(void) const
{
#if !defined No_Exception && !defined No_Standard_NoSuchObject
if (!More())
return ((MapNode *) myNode)->Value();
}
//! Value change access - denied
- virtual TheKeyType& ChangeValue(void) const
+ TheKeyType& ChangeValue(void) const
{
Standard_ImmutableObject::Raise("NCollection_Map::Iterator::ChangeValue");
return * (TheKeyType *) NULL; // For compiler
//! Constructor
NCollection_Map (const Standard_Integer NbBuckets = 1,
- const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
- : NCollection_BaseCollection<TheKeyType>(theAllocator),
- NCollection_BaseMap (NbBuckets, Standard_True) {}
+ const Handle(NCollection_BaseAllocator)& theAllocator = 0L) :
+ NCollection_BaseMap (NbBuckets, Standard_True, theAllocator) {}
//! Copy constructor
- NCollection_Map (const NCollection_Map& theOther)
- : NCollection_BaseCollection<TheKeyType>(theOther.myAllocator),
- NCollection_BaseMap (theOther.NbBuckets(), Standard_True)
+ NCollection_Map (const NCollection_Map& theOther) :
+ NCollection_BaseMap (theOther.NbBuckets(), Standard_True, theOther.myAllocator)
{ *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.
//! Notice that allocators will be swapped as well!
void Exchange (NCollection_Map& theOther)
{
- this->exchangeAllocators (theOther);
- this->exchangeMapsData (theOther);
+ this->exchangeMapsData (theOther);
}
- //! = another map
- NCollection_Map& operator= (const NCollection_Map& theOther)
+ //! Assign
+ NCollection_Map& Assign (const NCollection_Map& theOther)
{
if (this == &theOther)
return *this;
return *this;
}
+ //! Assign operator
+ NCollection_Map& operator= (const NCollection_Map& theOther)
+ {
+ return Assign(theOther);
+ }
+
//! ReSize
void ReSize (const Standard_Integer N)
{
NCollection_ListNode** newdata = 0L;
NCollection_ListNode** dummy = 0L;
Standard_Integer newBuck;
- if (BeginResize (N, newBuck, newdata, dummy, this->myAllocator))
+ if (BeginResize (N, newBuck, newdata, dummy))
{
if (myData1)
{
}
}
}
- EndResize (N, newBuck, newdata, dummy, this->myAllocator);
+ EndResize (N, newBuck, newdata, dummy);
}
}
//! Clear data. If doReleaseMemory is false then the table of
//! buckets is not released and will be reused.
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
- { Destroy (MapNode::delNode, this->myAllocator, doReleaseMemory); }
+ { Destroy (MapNode::delNode, doReleaseMemory); }
//! Clear data and reset allocator
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
{ Clear(); }
//! Size
- virtual Standard_Integer Size(void) const
+ Standard_Integer Size(void) const
{ return Extent(); }
public:
}
//!@}
-
- 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
#ifndef NCollection_Sequence_HeaderFile
#define NCollection_Sequence_HeaderFile
-#include <NCollection_BaseCollection.hxx>
#include <NCollection_BaseSequence.hxx>
#include <NCollection_StlIterator.hxx>
* Purpose: Definition of a sequence of elements indexed by
* an Integer in range of 1..n
*/
-template <class TheItemType> class NCollection_Sequence
- : public NCollection_BaseCollection<TheItemType>,
- public NCollection_BaseSequence
+template <class TheItemType>
+class NCollection_Sequence : public NCollection_BaseSequence
{
public:
//! STL-compliant typedef for value type
const TheItemType& Value () const { return myValue; }
//! Variable value access
TheItemType& ChangeValue () { return myValue; }
- //! Memory allocation
- DEFINE_STANDARD_ALLOC
- DEFINE_NCOLLECTION_ALLOC
private:
TheItemType myValue;
public:
//! Implementation of the Iterator interface.
- class Iterator : public NCollection_BaseCollection<TheItemType>::Iterator,
- public NCollection_BaseSequence::Iterator
+ class Iterator : public NCollection_BaseSequence::Iterator
{
public:
//! Empty constructor - for later Init
Iterator (const NCollection_Sequence& theSeq,
const Standard_Boolean isStart = Standard_True)
: NCollection_BaseSequence::Iterator (theSeq, isStart) {}
- //! Assignment
- Iterator& operator= (const Iterator& theIt)
- {
- NCollection_BaseSequence::Iterator& me = * this;
- me.operator= (theIt);
- return * this;
- }
//! Check end
- virtual Standard_Boolean More (void) const
+ Standard_Boolean More (void) const
{ return (myCurrent!=NULL); }
//! Make step
- virtual void Next (void)
+ void Next (void)
{
if (myCurrent)
{
}
}
//! Constant value access
- virtual const TheItemType& Value (void) const
+ const TheItemType& Value (void) const
{ return ((const Node *)myCurrent)->Value(); }
//! Variable value access
- virtual TheItemType& ChangeValue (void) const
+ TheItemType& ChangeValue (void) const
{ return ((Node *)myCurrent)->ChangeValue(); }
//! Performs comparison of two iterators.
- virtual Standard_Boolean IsEqual (const Iterator& theOther) const
+ Standard_Boolean IsEqual (const Iterator& theOther) const
{
return myCurrent == theOther.myCurrent;
}
// ---------- PUBLIC METHODS ------------
//! Constructor
- NCollection_Sequence(const Handle(NCollection_BaseAllocator)& theAllocator=0L)
- : NCollection_BaseCollection<TheItemType>(theAllocator),
- NCollection_BaseSequence() {}
+ NCollection_Sequence(const Handle(NCollection_BaseAllocator)& theAllocator=0L) :
+ NCollection_BaseSequence(theAllocator) {}
//! Copy constructor
NCollection_Sequence (const NCollection_Sequence& theOther) :
- NCollection_BaseCollection<TheItemType>(theOther.myAllocator),
- NCollection_BaseSequence()
- { *this = theOther; }
+ NCollection_BaseSequence(theOther.myAllocator)
+ {
+ Assign (theOther);
+ }
//! Number of items
- virtual Standard_Integer Size (void) const
+ Standard_Integer Size (void) const
{ return mySize; }
//! Number of items
//! Clear the items out, take a new allocator if non null
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator=0L)
{
- ClearSeq (delNode, this->myAllocator);
+ ClearSeq (delNode);
if (!theAllocator.IsNull())
this->myAllocator = theAllocator;
}
//! 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)
return *this;
return * this;
}
- //! Replace this sequence by the items of theOther collection
- virtual void Assign (const NCollection_BaseCollection<TheItemType>& theOther)
+ //! Replacement operator
+ NCollection_Sequence& operator= (const NCollection_Sequence& theOther)
{
- if (this == &theOther)
- return;
- Clear ();
- TYPENAME NCollection_BaseCollection<TheItemType>::Iterator& anIter =
- theOther.CreateIterator();
- for (; anIter.More(); anIter.Next())
- Append(anIter.Value());
+ return Assign (theOther);
}
//! Remove one item
void Remove (Iterator& thePosition)
- { RemoveSeq (thePosition, delNode, this->myAllocator); }
+ { RemoveSeq (thePosition, delNode); }
//! Remove one item
void Remove (const Standard_Integer theIndex)
- { RemoveSeq (theIndex, delNode, this->myAllocator); }
+ { RemoveSeq (theIndex, delNode); }
//! Remove range of items
void Remove (const Standard_Integer theFromIndex,
const Standard_Integer theToIndex)
- { RemoveSeq (theFromIndex, theToIndex, delNode, this->myAllocator); }
+ { RemoveSeq (theFromIndex, theToIndex, delNode); }
//! Append one item
void Append (const TheItemType& theItem)
~NCollection_Sequence (void)
{ Clear(); }
-
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 class Iterator;
+++ /dev/null
-// 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
//! iterator requires Offset and Differ methods. See NCollection_Vector as
//! example of declaring custom STL iterators.
template<class Category, class BaseIterator, class ItemType, bool IsConstant>
-class NCollection_StlIterator : private BaseIterator,
+class NCollection_StlIterator :
public std::iterator<Category, ItemType, ptrdiff_t,
typename opencascade::conditional<IsConstant, const ItemType*, ItemType*>::type,
typename opencascade::conditional<IsConstant, const ItemType&, ItemType&>::type>
//! Constructor from NCollection iterator
NCollection_StlIterator (const BaseIterator& theIterator)
- : BaseIterator (theIterator)
+ : myIterator (theIterator)
{ }
//! Cast from non-const variant to const one
NCollection_StlIterator (const NCollection_StlIterator<Category, BaseIterator, ItemType, false>& theIterator)
- : BaseIterator (theIterator)
+ : myIterator (theIterator.Iterator())
{ }
//! Assignment of non-const iterator to const one
NCollection_StlIterator& operator= (const NCollection_StlIterator<Category, BaseIterator, ItemType, false>& theIterator)
{
- BaseIterator::operator= (theIterator);
+ myIterator = theIterator.myIterator;
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
template<bool Condition>
typename opencascade::enable_if<!Condition, ItemType&>::type Reference()
{
- return BaseIterator::ChangeValue();
+ return myIterator.ChangeValue();
}
template<bool Condition>
typename opencascade::enable_if<Condition, const ItemType&>::type Reference()
{
- return BaseIterator::Value();
+ return myIterator.Value();
}
public: //! @name methods related to forward STL iterator
//! Test for equality
bool operator== (const NCollection_StlIterator& theOther) const
{
- return BaseIterator::More() == theOther.More() &&
- (!BaseIterator::More() || BaseIterator::IsEqual (theOther));
+ return myIterator.More() == theOther.myIterator.More() &&
+ (!myIterator.More() || myIterator.IsEqual (theOther.myIterator));
}
//! Test for inequality
//! Prefix increment
NCollection_StlIterator& operator++()
{
- BaseIterator::Next();
+ myIterator.Next();
return *this;
}
{
Standard_STATIC_ASSERT((opencascade::is_same<std::bidirectional_iterator_tag,Category>::value ||
opencascade::is_same<std::random_access_iterator_tag,Category>::value));
- BaseIterator::Previous();
+ myIterator.Previous();
return *this;
}
NCollection_StlIterator& operator+= (typename NCollection_StlIterator::difference_type theOffset)
{
Standard_STATIC_ASSERT((opencascade::is_same<std::random_access_iterator_tag,Category>::value));
- BaseIterator::Offset (theOffset);
+ myIterator.Offset (theOffset);
return *this;
}
typename NCollection_StlIterator::difference_type operator- (const NCollection_StlIterator& theOther) const
{
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
{
return !(*this < theOther);
}
+
+private:
+ //! NCollection iterator
+ BaseIterator myIterator;
};
#endif // NCollection_StlIterator_HeaderFile
#ifndef NCollection_TListIterator_HeaderFile
#define NCollection_TListIterator_HeaderFile
-#include <NCollection_BaseCollection.hxx>
#include <NCollection_BaseList.hxx>
#include <NCollection_TListNode.hxx>
* Remark: TListIterator is internal class
*/
template <class TheItemType> class NCollection_TListIterator
- : public NCollection_BaseCollection<TheItemType>::Iterator,
- public NCollection_BaseList::Iterator
+ : public NCollection_BaseList::Iterator
{
public:
//! Empty constructor - for later Init
//! Constructor with initialisation
NCollection_TListIterator (const NCollection_BaseList& 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
- virtual Standard_Boolean More (void) const
+ Standard_Boolean More (void) const
{ return (myCurrent!=NULL); }
//! Make step
- virtual void Next (void)
+ void Next (void)
{
myPrevious = myCurrent;
myCurrent = myCurrent->Next();
}
//! Constant Value access
- virtual const TheItemType& Value (void) const
+ const TheItemType& Value (void) const
{ return ((const NCollection_TListNode<TheItemType>*) myCurrent)->Value(); }
//! Variable Value access
- virtual TheItemType& ChangeValue (void) const
+ TheItemType& ChangeValue (void) const
{ return ((NCollection_TListNode<TheItemType> *)myCurrent)->ChangeValue(); }
};
#define NCollection_TListNode_HeaderFile
#include <NCollection_ListNode.hxx>
-#include <NCollection_BaseAllocator.hxx>
-#include <NCollection_DefineAlloc.hxx>
/**
* Purpose: Abstract list node class. Used by BaseList
const TheItemType& Value () const { return myValue; }
//! Variable value access
TheItemType& ChangeValue () { return myValue; }
- //! Memory allocation
- DEFINE_STANDARD_ALLOC
- DEFINE_NCOLLECTION_ALLOC
+
//! Static deleter to be passed to BaseList
static void delNode (NCollection_ListNode * theNode,
Handle(NCollection_BaseAllocator)& theAl)
template <class TheObjType, class TheBndType> class NCollection_UBTree
{
- public:
+public:
+ //! Memory allocation
+ DEFINE_STANDARD_ALLOC
+ DEFINE_NCOLLECTION_ALLOC
+
+public:
// ---------- PUBLIC TYPES ----------
/**
#define NCollection_Vector_HeaderFile
#include <NCollection_BaseVector.hxx>
-#include <NCollection_BaseCollection.hxx>
#include <NCollection_StlIterator.hxx>
//! Class NCollection_Vector (dynamic array of objects)
//! 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
//! to enlarge the vector during the iteration.
-template <class TheItemType> class NCollection_Vector
-: public NCollection_BaseCollection<TheItemType>,
- public NCollection_BaseVector
+template <class TheItemType>
+class NCollection_Vector : public NCollection_BaseVector
{
public:
//! STL-compliant typedef for value type
public:
//! Nested class Iterator
- class Iterator : public NCollection_BaseCollection<TheItemType>::Iterator,
- public NCollection_BaseVector::Iterator
+ class Iterator : public NCollection_BaseVector::Iterator
{
public:
}
//! Check end
- virtual Standard_Boolean More() const
+ Standard_Boolean More() const
{
return moreV();
}
//! Increment operator.
- virtual void Next()
+ void Next()
{
nextV();
}
//! Decrement operator.
- virtual void Previous()
+ void Previous()
{
prevV();
}
//! Offset operator.
- virtual void Offset (ptrdiff_t theOffset)
+ void Offset (ptrdiff_t theOffset)
{
- offsetV ((int)theOffset);
+ offsetV (static_cast<int>(theOffset));
}
//! Difference operator.
- virtual ptrdiff_t Differ (const Iterator& theOther) const
+ ptrdiff_t Differ (const Iterator& theOther) const
{
return differV (theOther);
}
//! Constant value access
- virtual const TheItemType& Value() const
+ const TheItemType& Value() const
{
return ((const TheItemType* )curBlockV()->DataPtr)[myCurIndex];
}
//! Variable value access
- virtual TheItemType& ChangeValue() const
+ TheItemType& ChangeValue() const
{
return ((TheItemType* )curBlockV()->DataPtr)[myCurIndex];
}
//! Performs comparison of two iterators.
- virtual Standard_Boolean IsEqual (const Iterator& theOther) const
+ Standard_Boolean IsEqual (const Iterator& theOther) const
{
return myVector == theOther.myVector
&& myCurIndex == theOther.myCurIndex
//! Constructor
NCollection_Vector (const Standard_Integer theIncrement = 256,
- const Handle(NCollection_BaseAllocator)& theAlloc = NULL)
- : NCollection_BaseCollection<TheItemType> (theAlloc),
- NCollection_BaseVector (NCollection_BaseCollection<TheItemType>::myAllocator, initMemBlocks, sizeof(TheItemType), theIncrement) {}
+ const Handle(NCollection_BaseAllocator)& theAlloc = NULL) :
+ NCollection_BaseVector (theAlloc, initMemBlocks, sizeof(TheItemType), theIncrement)
+ {}
//! Copy constructor
- NCollection_Vector (const NCollection_Vector& theOther)
- : NCollection_BaseCollection<TheItemType> (theOther.myAllocator),
- NCollection_BaseVector (NCollection_BaseCollection<TheItemType>::myAllocator, initMemBlocks, theOther)
+ NCollection_Vector (const NCollection_Vector& theOther) :
+ NCollection_BaseVector (theOther.myAllocator, initMemBlocks, theOther)
{
copyData (theOther);
}
{
initMemBlocks (*this, myData[anItemIter], 0, 0);
}
- NCollection_BaseCollection<TheItemType>::myAllocator->Free (myData);
- }
-
- //! Operator=
- NCollection_Vector& operator= (const NCollection_Vector& theOther)
- {
- Assign (theOther, Standard_False);
- return *this;
+ this->myAllocator->Free (myData);
}
//! Total number of items
}
//! Total number of items in the vector
- virtual Standard_Integer Size() const
+ Standard_Integer Size() const
{
return myLength;
}
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
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
- virtual TYPENAME NCollection_BaseCollection<TheItemType>::Iterator& CreateIterator() const
+ //! Assignment operator
+ NCollection_Vector& operator= (const NCollection_Vector& theOther)
{
- return *(new (this->IterAllocator()) Iterator(*this));
+ Assign (theOther, Standard_False);
+ return *this;
}
//! Append
TheItemType& Append (const TheItemType& theValue)
{
- TheItemType& anAppended = *(TheItemType* )expandV (NCollection_BaseCollection<TheItemType>::myAllocator, myLength);
+ TheItemType& anAppended = *(TheItemType* )expandV (myLength);
anAppended = theValue;
return anAppended;
}
const TheItemType& theValue)
{
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;
return *aVecValue;
}
{
initMemBlocks (*this, myData[anItemIter], 0, 0);
}
- NCollection_BaseCollection<TheItemType>::myAllocator->Free (myData);
+ this->myAllocator->Free (myData);
// allocate memory blocks with new allocator
if (!theOwnAllocator)
{
- NCollection_BaseCollection<TheItemType>::myAllocator = theOther.myAllocator;
+ this->myAllocator = theOther.myAllocator;
}
myIncrement = theOther.myIncrement;
myLength = theOther.myLength;
myNBlocks = (myLength == 0) ? 0 : (1 + (myLength - 1)/myIncrement);
myCapacity = GetCapacity (myIncrement) + myLength / myIncrement;
- myData = allocMemBlocks (NCollection_BaseCollection<TheItemType>::myAllocator, myCapacity);
+ myData = allocMemBlocks (myCapacity);
// copy data
copyData (theOther);
#define Prs3d_NListOfSequenceOfPnt_HeaderFile
#include <TColgp_SequenceOfPnt.hxx>
-#include <NCollection_DefineList.hxx>
-#include <NCollection_DefineBaseCollection.hxx>
+#include <NCollection_List.hxx>
-DEFINE_BASECOLLECTION(Prs3d_BaseCollListOfSequenceOfPnt,
- TColgp_SequenceOfPnt)
-DEFINE_LIST (Prs3d_NListOfSequenceOfPnt,
- Prs3d_BaseCollListOfSequenceOfPnt,
- TColgp_SequenceOfPnt)
+typedef NCollection_List<TColgp_SequenceOfPnt> Prs3d_NListOfSequenceOfPnt;
#endif
-
-
-
-
#ifndef _SelectMgr_DataMapOfObjectOwners_HeaderFile
#define _SelectMgr_DataMapOfObjectOwners_HeaderFile
-#include <NCollection_DefineDataMap.hxx>
+#include <NCollection_DataMap.hxx>
#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_SequenceOfOwner.hxx>
return (theH1 == theH2);
}
-DEFINE_BASECOLLECTION(SelectMgr_CollectionOfSequenceOfOwner, SelectMgr_SequenceOfOwner)
-DEFINE_DATAMAP(SelectMgr_DataMapOfObjectOwners, SelectMgr_CollectionOfSequenceOfOwner,
- Handle(SelectMgr_SelectableObject), SelectMgr_SequenceOfOwner)
-
-typedef SelectMgr_DataMapOfObjectOwners::Iterator
- SelectMgr_DataMapIteratorOfMapOfObjectOwners;
-
+typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), SelectMgr_SequenceOfOwner> SelectMgr_DataMapOfObjectOwners;
+typedef SelectMgr_DataMapOfObjectOwners::Iterator SelectMgr_DataMapIteratorOfMapOfObjectOwners;
#endif
#ifndef TObj_Container_HeaderFile
#define TObj_Container_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
-#include <NCollection_DefineDataMap.hxx>
-#include <NCollection_DefineSequence.hxx>
-#include <NCollection_DefineHSequence.hxx>
+#include <NCollection_DataMap.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_HExtendedString.hxx>
#include <TDF_Label.hxx>
#include <TObj_Common.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,
- Handle(TObj_HSequenceOfObject))
+typedef NCollection_DataMap<TCollection_AsciiString, Standard_Address> TObj_DataMapOfStringPointer;
-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
#include <TDF_Label.hxx>
#include <TObj_Partition.hxx>
-#include <NCollection_DefineBaseCollection.hxx>
-#include <NCollection_DefineDataMap.hxx>
#include <Message_Messenger.hxx>
class Handle(TObj_Application);
//! The Model Handle is defined in a separate header file
#endif
-
-#ifdef _MSC_VER
-#pragma once
-#endif
#ifndef TObj_SequenceOfIterator_HeaderFile
#define TObj_SequenceOfIterator_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
-#include <NCollection_DefineSequence.hxx>
-
+#include <NCollection_Sequence.hxx>
#include <TObj_ObjectIterator.hxx>
-DEFINE_BASECOLLECTION (TObj_CollectionOfIterator, Handle(TObj_ObjectIterator))
-DEFINE_SEQUENCE (TObj_SequenceOfIterator, TObj_CollectionOfIterator,
- Handle(TObj_ObjectIterator))
-
-#endif
+typedef NCollection_Sequence<Handle(TObj_ObjectIterator)> TObj_SequenceOfIterator;
-#ifdef _MSC_VER
-#pragma once
#endif
#ifndef TObj_SequenceOfObject_HeaderFile
#define TObj_SequenceOfObject_HeaderFile
-#include <NCollection_DefineBaseCollection.hxx>
-#include <NCollection_DefineSequence.hxx>
+#include <NCollection_Sequence.hxx>
#include <NCollection_DefineHSequence.hxx>
#include <TObj_Common.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,
- TObj_CollectionOfObject,Handle(TObj_Object))
-
-DEFINE_HSEQUENCE (TObj_HSequenceOfObject,
- TObj_SequenceOfObject)
+DEFINE_HSEQUENCE (TObj_HSequenceOfObject, TObj_SequenceOfObject)
#endif
void TObj_TNameContainer::Set(const TObj_DataMapOfNameLabel& theMap)
{
Backup();
- myMap = theMap;
+ myMap.Assign (theMap);
}
#ifndef _Visual3d_NListOfLayerItem_HeaderFile
#define _Visual3d_NListOfLayerItem_HeaderFile
-#include <NCollection_DefineList.hxx>
+#include <NCollection_List.hxx>
#include <Visual3d_LayerItem.hxx>
-DEFINE_LIST (Visual3d_NListOfLayerItem,
- NCollection_List,
- Handle(Visual3d_LayerItem))
+typedef NCollection_List<Handle(Visual3d_LayerItem)> Visual3d_NListOfLayerItem;
#endif
return one.ix == two.ix && one.iy == two.iy && one.iz == two.iz;
}
-#include <NCollection_DefineBaseCollection.hxx>
-DEFINE_BASECOLLECTION(iXYZbase, iXYZ)
+#include <NCollection_DataMap.hxx>
-#include <NCollection_DefineDataMap.hxx>
-DEFINE_DATAMAP(iXYZIndex, iXYZbase, iXYZ, Standard_Integer)
-DEFINE_DATAMAP(iXYZBool, iXYZbase, iXYZ, Standard_Byte)
+typedef NCollection_DataMap<iXYZ, Standard_Integer> iXYZIndex;
+typedef NCollection_DataMap<iXYZ, Standard_Byte> iXYZBool;
// Defines
#include <Standard_OStream.hxx>
#include <Standard_IStream.hxx>
#include <TCollection_ExtendedString.hxx>
+#include <NCollection_IncAllocator.hxx>
#include <Standard_Mutex.hxx>
struct VrmlData_InBuffer;