From: pkv Date: Wed, 22 Jul 2015 11:11:36 +0000 (+0300) Subject: 0026469: Methods Seek(), ChangeSeek() are missing in class NCollection_IndexedDataMap X-Git-Tag: V7_0_0_beta~401 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=031d5ab77ca28c93edece9222a92e5bd0aa7fbfc;p=occt.git 0026469: Methods Seek(), ChangeSeek() are missing in class NCollection_IndexedDataMap I. New features: 1.1. class NCollection_IndexedDataMap - method: const TheItemType* Seek(const TheKeyType& theKey1) const has been added. The method Seek returns pointer to Item by Key. Returns NULL if Key was not found. - method: TheItemType* ChangeSeek (const TheKeyType& theKey1) has been added. The method ChangeSeek returns modifiable pointer to Item by Key. Returns NULL if Key was not found. II. Changes: No changes. III. Modified entities: packages: NCollection --- diff --git a/src/NCollection/NCollection_IndexedDataMap.hxx b/src/NCollection/NCollection_IndexedDataMap.hxx index 72baad7265..05d4e32cb4 100644 --- a/src/NCollection/NCollection_IndexedDataMap.hxx +++ b/src/NCollection/NCollection_IndexedDataMap.hxx @@ -531,6 +531,33 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap return pNode1->ChangeValue(); } + //! Seek returns pointer to Item by Key. Returns + //! NULL if Key was not found. + const TheItemType* Seek(const TheKeyType& theKey1) const + { + return const_cast< NCollection_IndexedDataMap * >( this )->ChangeSeek(theKey1); + //NCollection_IndexedDataMap *pMap=(NCollection_IndexedDataMap *)this; + //return pMap->ChangeSeek(theKey1); + } + + //! ChangeSeek returns modifiable pointer to Item by Key. Returns + //! NULL if Key was not found. + TheItemType* ChangeSeek (const TheKeyType& theKey1) + { + if (!IsEmpty()) + { + IndexedDataMapNode * pNode1 = + (IndexedDataMapNode *) myData1[Hasher::HashCode(theKey1,NbBuckets())]; + while (pNode1) + { + if (Hasher::IsEqual (pNode1->Key1(), theKey1)) + return &pNode1->ChangeValue(); + pNode1 = (IndexedDataMapNode*) pNode1->Next(); + } + } + return 0L; + } + //! Find value for key with copying. //! @return true if key was found Standard_Boolean FindFromKey (const TheKeyType& theKey1,