-// File: NCollection_DataMap.hxx
-// Created: Thu Apr 24 15:02:53 2002
-// Author: Alexander KARTOMIN (akm)
-// <akm@opencascade.com>
+// Created on: 2002-04-24
+// Created by: Alexander KARTOMIN (akm)
+// Copyright (c) 2002-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and / or modify it
+// under the terms of the GNU Lesser General Public version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
#ifndef NCollection_DataMap_HeaderFile
#define NCollection_DataMap_HeaderFile
Standard_TypeMismatch::Raise ("NCollection_DataMap::Assign impossible");
}
+ //! Exchange the content of two maps without re-allocations.
+ //! Notice that allocators will be swapped as well!
+ void Exchange (NCollection_DataMap& theOther)
+ {
+ this->exchangeAllocators (theOther);
+ this->exchangeMapsData (theOther);
+ }
+
//! = another map
NCollection_DataMap& operator= (const NCollection_DataMap& theOther)
{
//! ReSize
void ReSize (const Standard_Integer N)
{
- DataMapNode** newdata = NULL;
- DataMapNode** dummy = NULL;
+ NCollection_ListNode** newdata = NULL;
+ NCollection_ListNode** dummy = NULL;
Standard_Integer newBuck;
- if (BeginResize (N, newBuck,
- (NCollection_ListNode**&)newdata,
- (NCollection_ListNode**&)dummy,
- this->myAllocator))
+ if (BeginResize (N, newBuck, newdata, dummy, this->myAllocator))
{
if (myData1)
{
}
}
}
- EndResize(N,newBuck,
- (NCollection_ListNode**&)newdata,
- (NCollection_ListNode**&)dummy,
- this->myAllocator);
+ EndResize (N, newBuck, newdata, dummy, this->myAllocator);
}
}
return p->Value(); // This for compiler
}
+ //! Find value for key with copying.
+ //! @return true if key was found
+ Standard_Boolean Find (const TheKeyType& theKey,
+ TheItemType& theValue) const
+ {
+ if (IsEmpty())
+ {
+ return Standard_False;
+ }
+
+ for (DataMapNode* aNodeIter = (DataMapNode* )myData1[Hasher::HashCode (theKey, NbBuckets())];
+ aNodeIter != NULL;
+ aNodeIter = (DataMapNode* )aNodeIter->Next())
+ {
+ if (Hasher::IsEqual (aNodeIter->Key(), theKey))
+ {
+ theValue = aNodeIter->Value();
+ return Standard_True;
+ }
+ }
+ return Standard_False;
+ }
+
//! operator ()
const TheItemType& operator() (const TheKeyType& theKey) const
{ return Find(theKey); }