TColStd_MapIteratorOfMapOfInteger.hxx
TColStd_MapIteratorOfMapOfReal.hxx
TColStd_MapIteratorOfMapOfTransient.hxx
-TColStd_MapIteratorOfPackedMapOfInteger.cxx
TColStd_MapIteratorOfPackedMapOfInteger.hxx
TColStd_MapOfAsciiString.hxx
TColStd_MapOfInteger.hxx
+++ /dev/null
-// Created on: 2005-12-09
-// Created by: Alexander GRIGORIEV
-// Copyright (c) 2005-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 License 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.
-
-#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
-#include <TColStd_PackedMapOfInteger.hxx>
-
-class TColStd_intMapNode;
-
-extern Standard_Integer TColStd_intMapNode_findNext (const TColStd_intMapNode *,
- unsigned int& );
-
-//=======================================================================
-//function : TColStd_MapIteratorOfPackedMapOfInteger
-//purpose : Constructor
-//=======================================================================
-
-TColStd_MapIteratorOfPackedMapOfInteger::TColStd_MapIteratorOfPackedMapOfInteger
- (const TColStd_PackedMapOfInteger& theMap)
- : TCollection_BasicMapIterator (theMap),
- myIntMask (~0U)
-{
- if (myNode) {
- const TColStd_intMapNode * aNode =
- reinterpret_cast <const TColStd_intMapNode *>(myNode);
- myKey = TColStd_intMapNode_findNext (aNode, myIntMask);
- }
-}
-
-
-//=======================================================================
-//function : Initialize
-//purpose :
-//=======================================================================
-
-void TColStd_MapIteratorOfPackedMapOfInteger::Initialize
- (const TColStd_PackedMapOfInteger& theMap)
-{
- TCollection_BasicMapIterator::Initialize (theMap);
- myIntMask = ~0U;
- if (myNode) {
- const TColStd_intMapNode * aNode =
- reinterpret_cast <const TColStd_intMapNode *>(myNode);
- myKey = TColStd_intMapNode_findNext (aNode, myIntMask);
- }
-}
-
-//=======================================================================
-//function : Reset
-//purpose :
-//=======================================================================
-
-void TColStd_MapIteratorOfPackedMapOfInteger::Reset ()
-{
- TCollection_BasicMapIterator::Reset();
- myIntMask = ~0U;
- if (myNode) {
- const TColStd_intMapNode * aNode =
- reinterpret_cast <const TColStd_intMapNode *>(myNode);
- myKey = TColStd_intMapNode_findNext (aNode, myIntMask);
- }
-}
-
-//=======================================================================
-//function : Next
-//purpose :
-//=======================================================================
-
-void TColStd_MapIteratorOfPackedMapOfInteger::Next ()
-{
- while (myNode) {
- const TColStd_intMapNode * aNode =
- reinterpret_cast <const TColStd_intMapNode *>(myNode);
- myKey = TColStd_intMapNode_findNext (aNode, myIntMask);
- if (myIntMask != ~0u)
- break;
- TCollection_BasicMapIterator::Next();
- }
-}
#ifndef TColStd_MapIteratorOfPackedMapOfInteger_HeaderFile
#define TColStd_MapIteratorOfPackedMapOfInteger_HeaderFile
-#include <TCollection_BasicMapIterator.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-class TColStd_PackedMapOfInteger;
-
-/**
- * Iterator of class TColStd_PackedMapOfInteger
- */
-
-class TColStd_MapIteratorOfPackedMapOfInteger: public TCollection_BasicMapIterator
-{
- public:
- // ---------- PUBLIC METHODS ----------
-
- /// Empty Constructor.
- inline TColStd_MapIteratorOfPackedMapOfInteger()
- : myIntMask (~0U), myKey (0) {}
-
- /// Constructor.
- Standard_EXPORT TColStd_MapIteratorOfPackedMapOfInteger
- (const TColStd_PackedMapOfInteger&);
-
- /// Re-initialize with the same or another Map instance.
- Standard_EXPORT void Initialize (const TColStd_PackedMapOfInteger&);
-
- /// Restart the iteraton
- Standard_EXPORT void Reset();
-
- /// Query the iterated key. Defined in TColStd_PackedMapOfInteger.cxx
- inline Standard_Integer Key () const
- {
- Standard_NoSuchObject_Raise_if ((myIntMask == ~0U),
- "TColStd_MapIteratorOfPackedMapOfInteger::Key");
- return myKey;
- }
-
- /// Increment the iterator
- Standard_EXPORT void Next();
-
-private:
- unsigned int myIntMask; ///< all bits set above the iterated position
- Standard_Integer myKey; ///< Currently iterated key
-};
+#include <TColStd_PackedMapOfInteger.hxx>
+//! Iterator of class TColStd_PackedMapOfInteger.
+typedef TColStd_PackedMapOfInteger::Iterator TColStd_MapIteratorOfPackedMapOfInteger;
#endif
// commercial license or contractual agreement.
#include <TColStd_PackedMapOfInteger.hxx>
-#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
+
#include <TCollection_MapNode.hxx>
#include <Standard_Type.hxx>
// 27 upper bits
#define MASK_HIGH (~MASK_LOW)
-/**
- * Class implementing a block of 32 consecutive integer values as a node of
- * a Map collection. The data are stored in 64 bits as:
- * - bits 0 - 4 : (number of integers stored in the block) - 1;
- * - bits 5 - 31: base address of the block of integers (low bits assumed 0)
- * - bits 32 - 63: 32-bit field where each bit indicates the presence of the
- * corresponding integer in the block. Number of non-zero bits
- * must be equal to the number expressed in bits 0-4.
- */
-class TColStd_intMapNode : public TCollection_MapNode
+//! Class implementing a block of 32 consecutive integer values as a node of a Map collection.
+class TColStd_PackedMapOfInteger::TColStd_intMapNode : public TCollection_MapNode
{
public:
inline TColStd_intMapNode (TCollection_MapNode * ptr = 0L)
return ((myMask >> 5) == (unsigned)theOther);
}
- /**
- * Local friend function, used in TColStd_MapIteratorOfPackedMapOfInteger.
- */
- friend Standard_Integer TColStd_intMapNode_findNext(const TColStd_intMapNode*,
- unsigned int& );
-
- /**
- * Local friend function.
- */
- friend Standard_Integer TColStd_intMapNode_findPrev(const TColStd_intMapNode*,
- unsigned int& );
-
private:
unsigned int myMask;
unsigned int myData;
//purpose :
//=======================================================================
-Standard_Boolean TColStd_intMapNode::AddValue (const Standard_Integer theValue)
+Standard_Boolean TColStd_PackedMapOfInteger::TColStd_intMapNode::AddValue (const Standard_Integer theValue)
{
Standard_Boolean aResult (Standard_False);
const Standard_Integer aValInt = (1 << (theValue & MASK_LOW));
//purpose :
//=======================================================================
-Standard_Boolean TColStd_intMapNode::DelValue (const Standard_Integer theValue)
+Standard_Boolean TColStd_PackedMapOfInteger::TColStd_intMapNode::DelValue (const Standard_Integer theValue)
{
Standard_Boolean aResult (Standard_False);
const Standard_Integer aValInt = (1 << (theValue & MASK_LOW));
//=======================================================================
//function : TColStd_intMapNode_findNext
-//purpose : Find the smallest non-zero bit under the given mask. Outputs
-// the new mask that does not contain the detected bit.
+//purpose :
//=======================================================================
-
-Standard_Integer TColStd_intMapNode_findNext (const TColStd_intMapNode* theNode,
- unsigned int& theMask)
+Standard_Integer TColStd_PackedMapOfInteger::TColStd_intMapNode_findNext (const TColStd_intMapNode* theNode,
+ unsigned int& theMask)
{
- unsigned int val = theNode->myData & theMask;
+ unsigned int val = theNode->Data() & theMask;
int nZeros (0);
if (val == 0)
theMask = ~0U; // void, nothing to do
//=======================================================================
//function : TColStd_intMapNode_findPrev
-//purpose : Find the highest non-zero bit under the given mask. Outputs
-// the new mask that does not contain the detected bit.
+//purpose :
//=======================================================================
-
-Standard_Integer TColStd_intMapNode_findPrev (const TColStd_intMapNode* theNode,
- unsigned int& theMask)
+Standard_Integer TColStd_PackedMapOfInteger::TColStd_intMapNode_findPrev (const TColStd_intMapNode* theNode,
+ unsigned int& theMask)
{
- unsigned int val = theNode->myData & theMask;
+ unsigned int val = theNode->Data() & theMask;
int nZeros (0);
if (val == 0)
theMask = ~0U; // void, nothing to do
#define TColStd_PackedMapOfInteger_HeaderFile
#include <Standard_DefineAlloc.hxx>
+#include <Standard_NoSuchObject.hxx>
#include <TCollection_BasicMap.hxx>
+#include <TCollection_BasicMapIterator.hxx>
/**
* Optimized Map of integer values. Each block of 32 integers is stored in 8 bytes in memory.
// operators new and delete must be defined explicitly
// since inherited ones are not accessible
DEFINE_STANDARD_ALLOC
-
- public:
- // ---------- PUBLIC METHODS ----------
+
+public:
+
+ //! Iterator of class TColStd_PackedMapOfInteger.
+ class Iterator : public TCollection_BasicMapIterator
+ {
+ public:
+
+ /// Empty Constructor.
+ Iterator() : myIntMask (~0U), myKey (0) {}
+
+ /// Constructor.
+ Iterator (const TColStd_PackedMapOfInteger& theMap)
+ : TCollection_BasicMapIterator (theMap),
+ myIntMask (~0U)
+ {
+ myKey = myNode != NULL ? TColStd_intMapNode_findNext (reinterpret_cast<const TColStd_intMapNode*>(myNode), myIntMask) : 0;
+ }
+
+ //! Re-initialize with the same or another Map instance.
+ void Initialize (const TColStd_PackedMapOfInteger& theMap)
+ {
+ TCollection_BasicMapIterator::Initialize (theMap);
+ myIntMask = ~0U;
+ myKey = myNode != NULL ? TColStd_intMapNode_findNext (reinterpret_cast<const TColStd_intMapNode*>(myNode), myIntMask) : 0;
+ }
+
+ //! Restart the iteration
+ void Reset()
+ {
+ TCollection_BasicMapIterator::Reset();
+ myIntMask = ~0U;
+ myKey = myNode != NULL ? TColStd_intMapNode_findNext (reinterpret_cast<const TColStd_intMapNode*>(myNode), myIntMask) : 0;
+ }
+
+ //! Query the iterated key.
+ Standard_Integer Key() const
+ {
+ Standard_NoSuchObject_Raise_if ((myIntMask == ~0U), "TColStd_MapIteratorOfPackedMapOfInteger::Key");
+ return myKey;
+ }
+
+ //! Increment the iterator
+ void Next()
+ {
+ for (; myNode != NULL; TCollection_BasicMapIterator::Next())
+ {
+ const TColStd_intMapNode* aNode = reinterpret_cast<const TColStd_intMapNode*>(myNode);
+ myKey = TColStd_intMapNode_findNext (aNode, myIntMask);
+ if (myIntMask != ~0u)
+ {
+ break;
+ }
+ }
+ }
+
+ private:
+ unsigned int myIntMask; //!< all bits set above the iterated position
+ Standard_Integer myKey; //!< Currently iterated key
+ };
+
+public:
/// Constructor
inline TColStd_PackedMapOfInteger (const Standard_Integer NbBuckets = 1)
inline Standard_Integer InternalExtent () const
{ return TCollection_BasicMap::Extent(); }
+private:
+
+ //! Class implementing a block of 32 consecutive integer values as a node of a Map collection.
+ //! The data are stored in 64 bits as:
+ //! - bits 0 - 4 : (number of integers stored in the block) - 1;
+ //! - bits 5 - 31: base address of the block of integers (low bits assumed 0)
+ //! - bits 32 - 63: 32-bit field where each bit indicates the presence of the corresponding integer in the block.
+ //! Number of non-zero bits must be equal to the number expressed in bits 0-4.
+ class TColStd_intMapNode;
- private:
- // ---------- PRIVATE FIELDS ----------
+ //! Find the smallest non-zero bit under the given mask.
+ //! Outputs the new mask that does not contain the detected bit.
+ Standard_EXPORT static Standard_Integer TColStd_intMapNode_findNext (const TColStd_intMapNode* theNode,
+ unsigned int& theMask);
- size_t myExtent;
+ //! Find the highest non-zero bit under the given mask.
+ //! Outputs the new mask that does not contain the detected bit.
+ Standard_EXPORT static Standard_Integer TColStd_intMapNode_findPrev (const TColStd_intMapNode* theNode,
+ unsigned int& theMask);
- friend class TColStd_MapIteratorOfPackedMapOfInteger;
+private:
+ size_t myExtent;
};
#endif