mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0028103: Foundation Classes - extend NCollection_Map to check whether two given maps are intersected
Mehtod HasIntersection added in NCollection_Map to check whether two given maps contain at least one same item. 'Draw' command and test to check the method were created.
This commit is contained in:
@@ -383,6 +383,28 @@ class NCollection_Map : public NCollection_BaseMap
|
||||
return anOldExtent != Extent();
|
||||
}
|
||||
|
||||
//! Returns true if this and theMap have common elements.
|
||||
Standard_Boolean HasIntersection (const NCollection_Map& theMap) const
|
||||
{
|
||||
const NCollection_Map* aMap1 = this;
|
||||
const NCollection_Map* aMap2 = &theMap;
|
||||
if (theMap.Size() < Size())
|
||||
{
|
||||
aMap1 = &theMap;
|
||||
aMap2 = this;
|
||||
}
|
||||
|
||||
for (NCollection_Map::Iterator aIt(*aMap1); aIt.More(); aIt.Next())
|
||||
{
|
||||
if (aMap2->Contains(aIt.Value()))
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//! Sets this Map to be the result of intersection (aka multiplication, common, boolean AND) operation between two given Maps.
|
||||
//! The new Map contains only the values that are contained in both map operands.
|
||||
//! All previous content of this Map is cleared.
|
||||
|
Reference in New Issue
Block a user