1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0026157: NCollection, TCollection packages - IndexedMap, IndexedDataMap ::Substitute() do not allow passing equal key for the same index

cosmetic remarks from msv
This commit is contained in:
apl
2015-04-30 14:55:07 +03:00
committed by bugmaster
parent d66bd706ce
commit 985aed12ec
5 changed files with 75 additions and 20 deletions

View File

@@ -163,11 +163,11 @@ Standard_Integer TCollection_IndexedDataMap::Add(const TheKey& K1, const TheItem
//=======================================================================
void TCollection_IndexedDataMap::Substitute(const Standard_Integer I,
const TheKey& K1,
const TheItem& T)
const TheKey& K1,
const TheItem& T)
{
Standard_OutOfRange_Raise_if(I < 1 || I > Extent(),
"IndexedMap::Substitute");
Standard_OutOfRange_Raise_if(I < 1 || I > Extent(), "IndexedDataMap::Substitute : "
"Index is out of range");
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
TCollection_IndexedDataMapNode* p;
@@ -175,8 +175,14 @@ void TCollection_IndexedDataMap::Substitute(const Standard_Integer I,
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
p = data1[k1];
while (p) {
if (Hasher::IsEqual(p->Key1(),K1))
Standard_DomainError::Raise("IndexedMap::Substitute");
if (Hasher::IsEqual(p->Key1(),K1)) {
if (p->Key2() != I)
Standard_DomainError::Raise("IndexedDataMap::Substitute : "
"Attempt to substitute existing key");
p->Key1() = K1;
p->Value() = T;
return;
}
p = (TCollection_IndexedDataMapNode*) p->Next();
}

View File

@@ -166,10 +166,10 @@ Standard_Integer TCollection_IndexedMap::Add(const TheKey& K1)
//=======================================================================
void TCollection_IndexedMap::Substitute(const Standard_Integer I,
const TheKey& K1)
const TheKey& K1)
{
Standard_OutOfRange_Raise_if(I < 1 || I > Extent(),
"IndexedMap::Substitute");
Standard_OutOfRange_Raise_if(I < 1 || I > Extent(), "IndexedMap::Substitute : "
"Index is out of range");
TCollection_IndexedMapNode** data1 = (TCollection_IndexedMapNode**)myData1;
TCollection_IndexedMapNode* p;
@@ -177,8 +177,13 @@ void TCollection_IndexedMap::Substitute(const Standard_Integer I,
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
p = data1[k1];
while (p) {
if (Hasher::IsEqual(p->Key1(),K1))
Standard_DomainError::Raise("IndexedMap::Substitute");
if (Hasher::IsEqual(p->Key1(),K1)) {
if (p->Key2() != I)
Standard_DomainError::Raise("IndexedMap::Substitute : "
"Attempt to substitute existing key");
p->Key1() = K1;
return;
}
p = (TCollection_IndexedMapNode*) p->Next();
}