Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Data Structures | Public Types | Public Member Functions | Static Public Attributes
NCollection_PackedMap< IntType > Class Template Reference

Optimized Map for integer values of various integral types. More...

#include <NCollection_PackedMap.hxx>

Data Structures

class  Iterator
 Iterator of class NCollection_PackedMap. More...
 

Public Types

using BlockType = typename std::conditional<Is64Bit, uint64_t, uint32_t>::type
 The block type for storing packed bits.
 
using IndexType = typename std::conditional<sizeof(IntType) <= 4, uint32_t, uint64_t>::type
 The index type for addressing blocks.
 

Public Member Functions

 NCollection_PackedMap (const size_t theNbBuckets=1)
 Constructor.
 
 NCollection_PackedMap (const int theNbBuckets)
 Constructor (legacy int-taking).
 
 NCollection_PackedMap (const NCollection_PackedMap &theOther)
 Copy constructor.
 
NCollection_PackedMapoperator= (const NCollection_PackedMap &theOther)
 
 NCollection_PackedMap (NCollection_PackedMap &&theOther) noexcept
 Move constructor.
 
NCollection_PackedMapoperator= (NCollection_PackedMap &&theOther) noexcept
 Move assignment operator.
 
NCollection_PackedMapAssign (const NCollection_PackedMap &theOther)
 Assignment operator.
 
void ReSize (const size_t theNbBuckets)
 Resize the map.
 
void ReSize (const int theNbBuckets)
 Resize the map (legacy int-taking).
 
void Clear ()
 Clear the map.
 
 ~NCollection_PackedMap ()
 
bool Add (const IntType theKey)
 Add a key to the map.
 
bool Contains (const IntType theKey) const
 Check if the map contains a key.
 
bool Remove (const IntType theKey)
 Remove a key from the map.
 
size_t NbBuckets () const
 Returns the number of map buckets.
 
int Extent () const
 Returns map extent (legacy int-returning API).
 
int Length () const
 Returns map extent (legacy int-returning API, synonym of Extent()).
 
size_t Size () const
 Returns map extent.
 
bool IsEmpty () const
 Returns TRUE if map is empty.
 
IntType GetMinimalMapped () const
 Query the minimal contained key value.
 
IntType GetMaximalMapped () const
 Query the maximal contained key value.
 

Static Public Attributes

static constexpr bool Is64Bit = sizeof(IntType) > 4
 True if the integer type is larger than 32 bits.
 
static constexpr int BitsPerBlock = Is64Bit ? 64 : 32
 Number of bits per block.
 

Deprecated boolean operations (use NCollection_PackedMapAlgo instead)

NCollection_PackedMapAlgo hxx instead void Union (const NCollection_PackedMap &theLeft, const NCollection_PackedMap &theRight)
 
NCollection_PackedMapAlgo hxx instead bool Unite (const NCollection_PackedMap &theOther)
 
NCollection_PackedMapAlgo hxx instead void Intersection (const NCollection_PackedMap &theLeft, const NCollection_PackedMap &theRight)
 
NCollection_PackedMapAlgo hxx instead bool Intersect (const NCollection_PackedMap &theOther)
 
NCollection_PackedMapAlgo hxx instead void Subtraction (const NCollection_PackedMap &theLeft, const NCollection_PackedMap &theRight)
 
NCollection_PackedMapAlgo hxx instead bool Subtract (const NCollection_PackedMap &theOther)
 
NCollection_PackedMapAlgo hxx instead void Difference (const NCollection_PackedMap &theLeft, const NCollection_PackedMap &theRight)
 
NCollection_PackedMapAlgo hxx instead bool Differ (const NCollection_PackedMap &theOther)
 
NCollection_PackedMapAlgo hxx instead bool IsEqual (const NCollection_PackedMap &theOther) const
 
NCollection_PackedMapAlgo hxx instead bool IsSubset (const NCollection_PackedMap &theOther) const
 
NCollection_PackedMapAlgo hxx instead bool HasIntersection (const NCollection_PackedMap &theOther) const
 
NCollection_PackedMapAlgo hxx instead bool Contains (const NCollection_PackedMap &theOther) const
 
bool Resizable () const
 Returns TRUE if resizing the map should be considered.
 
static IndexType packedKeyIndex (IntType theKey)
 Return an integer index for specified key.
 
static size_t hashCode (IndexType theKeyIndex, size_t theNbBuckets)
 Compute hash code for a key index.
 
static size_t population (IndexType &theMask, BlockType theData)
 Compute the population (i.e., the number of non-zero bits) of the block. The population is stored decremented as it is defined in PackedMapNode.
 
static IntType findNext (const PackedMapNode *theNode, BlockType &theMask)
 Find the smallest non-zero bit under the given mask. Outputs the new mask that does not contain the detected bit.
 
static IntType findPrev (const PackedMapNode *theNode, BlockType &theMask)
 Find the highest non-zero bit under the given mask. Outputs the new mask that does not contain the detected bit.
 

Detailed Description

template<typename IntType>
class NCollection_PackedMap< IntType >

Optimized Map for integer values of various integral types.

This template class provides a memory-efficient storage for sets of integers. Each block of BitsPerBlock (32 or 64) consecutive integers is stored compactly using bit manipulation. The block size is automatically selected based on the integer type: 32 bits for int/unsigned, 64 bits for int64_t/size_t.

Template Parameters
IntTypeThe integral type to store (int, unsigned int, int64_t, size_t, etc.)

Member Typedef Documentation

◆ BlockType

template<typename IntType >
using NCollection_PackedMap< IntType >::BlockType = typename std::conditional<Is64Bit, uint64_t, uint32_t>::type

The block type for storing packed bits.

◆ IndexType

template<typename IntType >
using NCollection_PackedMap< IntType >::IndexType = typename std::conditional<sizeof(IntType) <= 4, uint32_t, uint64_t>::type

The index type for addressing blocks.

Constructor & Destructor Documentation

◆ NCollection_PackedMap() [1/4]

template<typename IntType >
NCollection_PackedMap< IntType >::NCollection_PackedMap ( const size_t theNbBuckets = 1)
inline

Constructor.

◆ NCollection_PackedMap() [2/4]

template<typename IntType >
NCollection_PackedMap< IntType >::NCollection_PackedMap ( const int theNbBuckets)
inline

Constructor (legacy int-taking).

◆ NCollection_PackedMap() [3/4]

Copy constructor.

◆ NCollection_PackedMap() [4/4]

Move constructor.

◆ ~NCollection_PackedMap()

Member Function Documentation

◆ Add()

template<typename IntType >
bool NCollection_PackedMap< IntType >::Add ( const IntType theKey)
inline

Add a key to the map.

Parameters
[in]theKeythe key to add
Returns
true if the key was added, false if it already existed

◆ Assign()

template<typename IntType >
NCollection_PackedMap & NCollection_PackedMap< IntType >::Assign ( const NCollection_PackedMap< IntType > & theOther)
inline

Assignment operator.

◆ Clear()

template<typename IntType >
void NCollection_PackedMap< IntType >::Clear ( )
inline

Clear the map.

◆ Contains() [1/2]

template<typename IntType >
bool NCollection_PackedMap< IntType >::Contains ( const IntType theKey) const
inline

Check if the map contains a key.

Parameters
[in]theKeythe key to check
Returns
true if the key is in the map

◆ Contains() [2/2]

template<typename IntType >
bool NCollection_PackedMap< IntType >::Contains ( const NCollection_PackedMap< IntType > & theOther) const
Deprecated

Use NCollection_PackedMapAlgo::Contains() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

◆ Differ()

template<typename IntType >
bool NCollection_PackedMap< IntType >::Differ ( const NCollection_PackedMap< IntType > & theOther)
Deprecated

Use NCollection_PackedMapAlgo::Differ() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

◆ Difference()

template<typename IntType >
void NCollection_PackedMap< IntType >::Difference ( const NCollection_PackedMap< IntType > & theLeft,
const NCollection_PackedMap< IntType > & theRight )
Deprecated

Use NCollection_PackedMapAlgo::Difference() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

◆ Extent()

template<typename IntType >
int NCollection_PackedMap< IntType >::Extent ( ) const
inline

Returns map extent (legacy int-returning API).

◆ findNext()

template<typename IntType >
static IntType NCollection_PackedMap< IntType >::findNext ( const PackedMapNode * theNode,
BlockType & theMask )
inlinestaticprotected

Find the smallest non-zero bit under the given mask. Outputs the new mask that does not contain the detected bit.

◆ findPrev()

template<typename IntType >
static IntType NCollection_PackedMap< IntType >::findPrev ( const PackedMapNode * theNode,
BlockType & theMask )
inlinestaticprotected

Find the highest non-zero bit under the given mask. Outputs the new mask that does not contain the detected bit.

◆ GetMaximalMapped()

template<typename IntType >
IntType NCollection_PackedMap< IntType >::GetMaximalMapped ( ) const
inline

Query the maximal contained key value.

◆ GetMinimalMapped()

template<typename IntType >
IntType NCollection_PackedMap< IntType >::GetMinimalMapped ( ) const
inline

Query the minimal contained key value.

◆ hashCode()

template<typename IntType >
static size_t NCollection_PackedMap< IntType >::hashCode ( IndexType theKeyIndex,
size_t theNbBuckets )
inlinestaticprotected

Compute hash code for a key index.

◆ HasIntersection()

template<typename IntType >
bool NCollection_PackedMap< IntType >::HasIntersection ( const NCollection_PackedMap< IntType > & theOther) const
Deprecated

Use NCollection_PackedMapAlgo::HasIntersection() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

◆ Intersect()

template<typename IntType >
bool NCollection_PackedMap< IntType >::Intersect ( const NCollection_PackedMap< IntType > & theOther)
Deprecated

Use NCollection_PackedMapAlgo::Intersect() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

◆ Intersection()

template<typename IntType >
void NCollection_PackedMap< IntType >::Intersection ( const NCollection_PackedMap< IntType > & theLeft,
const NCollection_PackedMap< IntType > & theRight )
Deprecated

Use NCollection_PackedMapAlgo::Intersection() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

◆ IsEmpty()

template<typename IntType >
bool NCollection_PackedMap< IntType >::IsEmpty ( ) const
inline

Returns TRUE if map is empty.

◆ IsEqual()

template<typename IntType >
bool NCollection_PackedMap< IntType >::IsEqual ( const NCollection_PackedMap< IntType > & theOther) const
Deprecated

Use NCollection_PackedMapAlgo::IsEqual() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

◆ IsSubset()

template<typename IntType >
bool NCollection_PackedMap< IntType >::IsSubset ( const NCollection_PackedMap< IntType > & theOther) const
Deprecated

Use NCollection_PackedMapAlgo::IsSubset() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

◆ Length()

template<typename IntType >
int NCollection_PackedMap< IntType >::Length ( ) const
inline

Returns map extent (legacy int-returning API, synonym of Extent()).

◆ NbBuckets()

template<typename IntType >
size_t NCollection_PackedMap< IntType >::NbBuckets ( ) const
inline

Returns the number of map buckets.

◆ operator=() [1/2]

◆ operator=() [2/2]

Move assignment operator.

◆ packedKeyIndex()

template<typename IntType >
static IndexType NCollection_PackedMap< IntType >::packedKeyIndex ( IntType theKey)
inlinestaticprotected

Return an integer index for specified key.

◆ population()

template<typename IntType >
static size_t NCollection_PackedMap< IntType >::population ( IndexType & theMask,
BlockType theData )
inlinestaticprotected

Compute the population (i.e., the number of non-zero bits) of the block. The population is stored decremented as it is defined in PackedMapNode.

◆ Remove()

template<typename IntType >
bool NCollection_PackedMap< IntType >::Remove ( const IntType theKey)
inline

Remove a key from the map.

Parameters
[in]theKeythe key to remove
Returns
true if the key was removed, false if it was not present

◆ Resizable()

template<typename IntType >
bool NCollection_PackedMap< IntType >::Resizable ( ) const
inlineprotected

Returns TRUE if resizing the map should be considered.

◆ ReSize() [1/2]

template<typename IntType >
void NCollection_PackedMap< IntType >::ReSize ( const int theNbBuckets)
inline

Resize the map (legacy int-taking).

◆ ReSize() [2/2]

template<typename IntType >
void NCollection_PackedMap< IntType >::ReSize ( const size_t theNbBuckets)
inline

Resize the map.

◆ Size()

template<typename IntType >
size_t NCollection_PackedMap< IntType >::Size ( ) const
inline

Returns map extent.

◆ Subtract()

template<typename IntType >
bool NCollection_PackedMap< IntType >::Subtract ( const NCollection_PackedMap< IntType > & theOther)
Deprecated

Use NCollection_PackedMapAlgo::Subtract() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

◆ Subtraction()

template<typename IntType >
void NCollection_PackedMap< IntType >::Subtraction ( const NCollection_PackedMap< IntType > & theLeft,
const NCollection_PackedMap< IntType > & theRight )
Deprecated

Use NCollection_PackedMapAlgo::Subtraction() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

◆ Union()

template<typename IntType >
void NCollection_PackedMap< IntType >::Union ( const NCollection_PackedMap< IntType > & theLeft,
const NCollection_PackedMap< IntType > & theRight )
Deprecated

Use NCollection_PackedMapAlgo::Union() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

◆ Unite()

template<typename IntType >
bool NCollection_PackedMap< IntType >::Unite ( const NCollection_PackedMap< IntType > & theOther)
Deprecated

Use NCollection_PackedMapAlgo::Unite() instead

("This method will be removed after OCCT 7.9 release. Use methods from "

Field Documentation

◆ BitsPerBlock

template<typename IntType >
constexpr int NCollection_PackedMap< IntType >::BitsPerBlock = Is64Bit ? 64 : 32
staticconstexpr

Number of bits per block.

◆ Is64Bit

template<typename IntType >
constexpr bool NCollection_PackedMap< IntType >::Is64Bit = sizeof(IntType) > 4
staticconstexpr

True if the integer type is larger than 32 bits.


The documentation for this class was generated from the following file: