]> OCCT Git - occt.git/commitdiff
0026469: Methods Seek(), ChangeSeek() are missing in class NCollection_IndexedDataMap
authorpkv <pkv@opencascade.com>
Wed, 22 Jul 2015 11:11:36 +0000 (14:11 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 29 Jul 2015 12:11:16 +0000 (15:11 +0300)
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

src/NCollection/NCollection_IndexedDataMap.hxx

index 72baad726507d2cb71624cde3cb3c08339d2585a..05d4e32cb4e5492c9f28a66dd0d00ed6c5114c0b 100644 (file)
@@ -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,