mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0029740
: Draw Harness - eliminate redundant casts to AIS_InteractiveObject
NCollecton_DoubleMap has been extended with two new methods Find1() and Find2() performing lookup and returning found key withoout throwing an exception (similar to NCollection_DataMap::Find()). ViewerTest_DoubleMapOfInteractiveAndName has been redeclared to define Handle(AIS_InteractiveObject) key instead of Handle(Standard_Transient).
This commit is contained in:
@@ -398,7 +398,8 @@ public:
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//! Find1
|
||||
//! Find the Key1 and return Key2 value.
|
||||
//! Raises an exception if Key1 was not bound.
|
||||
const TheKey2Type& Find1(const TheKey1Type& theKey1) const
|
||||
{
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DoubleMap::Find1");
|
||||
@@ -413,7 +414,27 @@ public:
|
||||
throw Standard_NoSuchObject("NCollection_DoubleMap::Find1");
|
||||
}
|
||||
|
||||
//! Find2
|
||||
//! Find the Key1 and return Key2 value (by copying its value).
|
||||
//! @param [in] theKey1 Key1 to find
|
||||
//! @param [out] theKey2 Key2 to return
|
||||
//! @return TRUE if Key1 has been found
|
||||
Standard_Boolean Find1 (const TheKey1Type& theKey1,
|
||||
TheKey2Type& theKey2) const
|
||||
{
|
||||
for (DoubleMapNode* aNode1 = !IsEmpty() ? (DoubleMapNode* )myData1[Hasher1::HashCode (theKey1, NbBuckets())] : NULL;
|
||||
aNode1 != NULL; aNode1 = (DoubleMapNode* )aNode1->Next())
|
||||
{
|
||||
if (Hasher1::IsEqual (aNode1->Key1(), theKey1))
|
||||
{
|
||||
theKey2 = aNode1->Key2();
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//! Find the Key2 and return Key1 value.
|
||||
//! Raises an exception if Key2 was not bound.
|
||||
const TheKey1Type& Find2(const TheKey2Type& theKey2) const
|
||||
{
|
||||
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DoubleMap::Find2");
|
||||
@@ -428,6 +449,25 @@ public:
|
||||
throw Standard_NoSuchObject("NCollection_DoubleMap::Find2");
|
||||
}
|
||||
|
||||
//! Find the Key2 and return Key1 value (by copying its value).
|
||||
//! @param [in] theKey2 Key2 to find
|
||||
//! @param [out] theKey1 Key1 to return
|
||||
//! @return TRUE if Key2 has been found
|
||||
Standard_Boolean Find2 (const TheKey2Type& theKey2,
|
||||
TheKey1Type& theKey1) const
|
||||
{
|
||||
for (DoubleMapNode* aNode2 = !IsEmpty() ? (DoubleMapNode* )myData2[Hasher2::HashCode (theKey2, NbBuckets())] : NULL;
|
||||
aNode2 != NULL; aNode2 = (DoubleMapNode* )aNode2->Next2())
|
||||
{
|
||||
if (Hasher2::IsEqual (aNode2->Key2(), theKey2))
|
||||
{
|
||||
theKey1 = aNode2->Key1();
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//! 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)
|
||||
|
Reference in New Issue
Block a user