mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0021212: Missing Hasher parmeter in current implementation of NCollection Map-s
This commit is contained in:
@@ -11,6 +11,9 @@
|
||||
#include <NCollection_TListNode.hxx>
|
||||
#include <Standard_TypeMismatch.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
|
||||
#include <NCollection_DefaultHasher.hxx>
|
||||
|
||||
#if !defined No_Exception && !defined No_Standard_OutOfRange
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#endif
|
||||
@@ -39,7 +42,11 @@
|
||||
* See the class Map from NCollection for a
|
||||
* discussion about the number of buckets.
|
||||
*/
|
||||
template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
|
||||
template < class TheKeyType,
|
||||
class TheItemType,
|
||||
class Hasher = NCollection_DefaultHasher<TheKeyType> >
|
||||
class NCollection_IndexedDataMap
|
||||
: public NCollection_BaseCollection<TheItemType>,
|
||||
public NCollection_BaseMap
|
||||
{
|
||||
@@ -167,8 +174,8 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
{
|
||||
TheKeyType aKey1 = theOther.FindKey(i);
|
||||
TheItemType anItem = theOther.FindFromIndex(i);
|
||||
Standard_Integer iK1 = HashCode (aKey1, NbBuckets());
|
||||
Standard_Integer iK2 = HashCode (i, NbBuckets());
|
||||
Standard_Integer iK1 = Hasher::HashCode (aKey1, NbBuckets());
|
||||
Standard_Integer iK2 = ::HashCode (i, NbBuckets());
|
||||
IndexedDataMapNode * pNode =
|
||||
new (this->myAllocator) IndexedDataMapNode (aKey1, i, anItem,
|
||||
myData1[iK1], myData2[iK2]);
|
||||
@@ -201,8 +208,8 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
p = (IndexedDataMapNode *) myData1[i];
|
||||
while (p)
|
||||
{
|
||||
iK1 = HashCode (p->Key1(), newBuck);
|
||||
iK2 = HashCode (p->Key2(), newBuck);
|
||||
iK1 = Hasher::HashCode (p->Key1(), newBuck);
|
||||
iK2 = ::HashCode (p->Key2(), newBuck);
|
||||
q = (IndexedDataMapNode*) p->Next();
|
||||
p->Next() = ppNewData1[iK1];
|
||||
p->Next2() = ppNewData2[iK2];
|
||||
@@ -225,17 +232,17 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
{
|
||||
if (Resizable())
|
||||
ReSize(Extent());
|
||||
Standard_Integer iK1 = HashCode (theKey1, NbBuckets());
|
||||
Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
|
||||
IndexedDataMapNode * pNode;
|
||||
pNode = (IndexedDataMapNode *) myData1[iK1];
|
||||
while (pNode)
|
||||
{
|
||||
if (IsEqual (pNode->Key1(), theKey1))
|
||||
if (Hasher::IsEqual (pNode->Key1(), theKey1))
|
||||
return pNode->Key2();
|
||||
pNode = (IndexedDataMapNode *) pNode->Next();
|
||||
}
|
||||
Increment();
|
||||
Standard_Integer iK2 = HashCode(Extent(),NbBuckets());
|
||||
Standard_Integer iK2 = ::HashCode(Extent(),NbBuckets());
|
||||
pNode = new (this->myAllocator) IndexedDataMapNode (theKey1, Extent(), theItem,
|
||||
myData1[iK1], myData2[iK2]);
|
||||
myData1[iK1] = pNode;
|
||||
@@ -248,12 +255,12 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
{
|
||||
if (IsEmpty())
|
||||
return Standard_False;
|
||||
Standard_Integer iK1 = HashCode (theKey1, NbBuckets());
|
||||
Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
|
||||
IndexedDataMapNode * pNode1;
|
||||
pNode1 = (IndexedDataMapNode *) myData1[iK1];
|
||||
while (pNode1)
|
||||
{
|
||||
if (IsEqual(pNode1->Key1(), theKey1))
|
||||
if (Hasher::IsEqual(pNode1->Key1(), theKey1))
|
||||
return Standard_True;
|
||||
pNode1 = (IndexedDataMapNode *) pNode1->Next();
|
||||
}
|
||||
@@ -271,17 +278,17 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
#endif
|
||||
IndexedDataMapNode * p;
|
||||
// check if theKey1 is not already in the map
|
||||
Standard_Integer iK1 = HashCode (theKey1, NbBuckets());
|
||||
Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
|
||||
p = (IndexedDataMapNode *) myData1[iK1];
|
||||
while (p)
|
||||
{
|
||||
if (IsEqual (p->Key1(), theKey1))
|
||||
if (Hasher::IsEqual (p->Key1(), theKey1))
|
||||
Standard_DomainError::Raise("NCollection_IndexedDataMap::Substitute");
|
||||
p = (IndexedDataMapNode *) p->Next();
|
||||
}
|
||||
|
||||
// Find the node for the index I
|
||||
Standard_Integer iK2 = HashCode (theIndex, NbBuckets());
|
||||
Standard_Integer iK2 = ::HashCode (theIndex, NbBuckets());
|
||||
p = (IndexedDataMapNode *) myData2[iK2];
|
||||
while (p)
|
||||
{
|
||||
@@ -291,7 +298,7 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
}
|
||||
|
||||
// remove the old key
|
||||
Standard_Integer iK = HashCode (p->Key1(), NbBuckets());
|
||||
Standard_Integer iK = Hasher::HashCode (p->Key1(), NbBuckets());
|
||||
IndexedDataMapNode * q = (IndexedDataMapNode *) myData1[iK];
|
||||
if (q == p)
|
||||
myData1[iK] = (IndexedDataMapNode *) p->Next();
|
||||
@@ -318,7 +325,7 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
#endif
|
||||
IndexedDataMapNode * p, * q;
|
||||
// Find the node for the last index and remove it
|
||||
Standard_Integer iK2 = HashCode (Extent(), NbBuckets());
|
||||
Standard_Integer iK2 = ::HashCode (Extent(), NbBuckets());
|
||||
p = (IndexedDataMapNode *) myData2[iK2];
|
||||
q = NULL;
|
||||
while (p)
|
||||
@@ -334,7 +341,7 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
q->Next2() = p->Next2();
|
||||
|
||||
// remove the key
|
||||
Standard_Integer iK1 = HashCode (p->Key1(), NbBuckets());
|
||||
Standard_Integer iK1 = Hasher::HashCode (p->Key1(), NbBuckets());
|
||||
q = (IndexedDataMapNode *) myData1[iK1];
|
||||
if (q == p)
|
||||
myData1[iK1] = (IndexedDataMapNode *) p->Next();
|
||||
@@ -357,7 +364,7 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::FindKey");
|
||||
#endif
|
||||
IndexedDataMapNode * pNode2 =
|
||||
(IndexedDataMapNode *) myData2[HashCode(theKey2,NbBuckets())];
|
||||
(IndexedDataMapNode *) myData2[::HashCode(theKey2,NbBuckets())];
|
||||
while (pNode2)
|
||||
{
|
||||
if (pNode2->Key2() == theKey2)
|
||||
@@ -376,7 +383,7 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::FindFromIndex");
|
||||
#endif
|
||||
IndexedDataMapNode * pNode2 =
|
||||
(IndexedDataMapNode *) myData2[HashCode(theKey2,NbBuckets())];
|
||||
(IndexedDataMapNode *) myData2[::HashCode(theKey2,NbBuckets())];
|
||||
while (pNode2)
|
||||
{
|
||||
if (pNode2->Key2() == theKey2)
|
||||
@@ -399,7 +406,7 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
Standard_OutOfRange::Raise("NCollection_IndexedDataMap::ChangeFromIndex");
|
||||
#endif
|
||||
IndexedDataMapNode * pNode2 =
|
||||
(IndexedDataMapNode *) myData2[HashCode(theKey2,NbBuckets())];
|
||||
(IndexedDataMapNode *) myData2[::HashCode(theKey2,NbBuckets())];
|
||||
while (pNode2)
|
||||
{
|
||||
if (pNode2->Key2() == theKey2)
|
||||
@@ -419,10 +426,10 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
{
|
||||
if (IsEmpty()) return 0;
|
||||
IndexedDataMapNode * pNode1 =
|
||||
(IndexedDataMapNode *) myData1[HashCode(theKey1,NbBuckets())];
|
||||
(IndexedDataMapNode *) myData1[Hasher::HashCode(theKey1,NbBuckets())];
|
||||
while (pNode1)
|
||||
{
|
||||
if (IsEqual (pNode1->Key1(), theKey1))
|
||||
if (Hasher::IsEqual (pNode1->Key1(), theKey1))
|
||||
return pNode1->Key2();
|
||||
pNode1 = (IndexedDataMapNode*) pNode1->Next();
|
||||
}
|
||||
@@ -437,10 +444,10 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
Standard_NoSuchObject::Raise ("NCollection_IndexedDataMap::FindFromKey");
|
||||
#endif
|
||||
IndexedDataMapNode * pNode1 =
|
||||
(IndexedDataMapNode *) myData1[HashCode(theKey1,NbBuckets())];
|
||||
(IndexedDataMapNode *) myData1[Hasher::HashCode(theKey1,NbBuckets())];
|
||||
while (pNode1)
|
||||
{
|
||||
if (IsEqual (pNode1->Key1(), theKey1))
|
||||
if (Hasher::IsEqual (pNode1->Key1(), theKey1))
|
||||
return pNode1->Value();
|
||||
pNode1 = (IndexedDataMapNode*) pNode1->Next();
|
||||
}
|
||||
@@ -456,10 +463,10 @@ template <class TheKeyType, class TheItemType> class NCollection_IndexedDataMap
|
||||
Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::ChangeFromKey");
|
||||
#endif
|
||||
IndexedDataMapNode * pNode1 =
|
||||
(IndexedDataMapNode *) myData1[HashCode(theKey1,NbBuckets())];
|
||||
(IndexedDataMapNode *) myData1[Hasher::HashCode(theKey1,NbBuckets())];
|
||||
while (pNode1)
|
||||
{
|
||||
if (IsEqual (pNode1->Key1(), theKey1))
|
||||
if (Hasher::IsEqual (pNode1->Key1(), theKey1))
|
||||
return pNode1->ChangeValue();
|
||||
pNode1 = (IndexedDataMapNode*) pNode1->Next();
|
||||
}
|
||||
|
Reference in New Issue
Block a user