#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