0024911: Avoid using virtual functions in NCollection classes

NCollection_BaseCollection class, relevant header files, and macro DEFINE_BASECOLLECTION removed.
Hence methods Assign() from other compatible (via inheritance of BaseCollection) collections are not available any more, as well as base Iterator class.

All methods of Iterator classes are made non-virtual, allowing their inline expansion for better performance.

OCCT-specific operators new and delete added to collection classes and removed from iterator classes.
This commit is contained in:
abv
2014-05-08 09:13:00 +04:00
committed by apn
parent 598fcce93c
commit ddf2fe8eeb
66 changed files with 456 additions and 1016 deletions

View File

@@ -26,6 +26,7 @@
#define NCollection_BaseList_HeaderFile
#include <Standard_NoSuchObject.hxx>
#include <NCollection_DefineAlloc.hxx>
#include <NCollection_ListNode.hxx>
typedef void (* NCollection_DelListNode)
@@ -34,7 +35,12 @@ typedef void (* NCollection_DelListNode)
// ********************************************************** BaseList class
class NCollection_BaseList
{
public:
public:
//! Memory allocation
DEFINE_STANDARD_ALLOC
DEFINE_NCOLLECTION_ALLOC
public:
class Iterator
{
public:
@@ -78,7 +84,7 @@ class NCollection_BaseList
}
//-------------------------------------------------------
//! Performs comparison of two iterators
virtual Standard_Boolean IsEqual (const Iterator& theOther) const
Standard_Boolean IsEqual (const Iterator& theOther) const
{
return *this == theOther;
}
@@ -113,15 +119,17 @@ class NCollection_BaseList
// ******** 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
@@ -162,15 +170,13 @@ class NCollection_BaseList
// ******** 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]
@@ -197,7 +203,8 @@ class NCollection_BaseList
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