Open CASCADE Technology  7.3.1.dev
Data Structures | Public Member Functions
NCollection_SparseArray< TheItemType > Class Template Reference

#include <NCollection_SparseArray.hxx>

Inheritance diagram for NCollection_SparseArray< TheItemType >:
Inheritance graph
[legend]

Data Structures

class  ConstIterator
 
class  Iterator
 

Public Member Functions

 NCollection_SparseArray (Standard_Size theIncrement)
 Constructor; accepts size of blocks. More...
 
NCollection_SparseArrayAssign (const NCollection_SparseArray &theOther)
 Explicit assignment operator. More...
 
void Exchange (NCollection_SparseArray &theOther)
 Exchange the data of two arrays; can be used primarily to move contents of theOther into the new array in a fast way (without creation of duplicated data) More...
 
virtual ~NCollection_SparseArray ()
 Destructor. More...
 
Array-like interface (in addition to inherited methods)
const TheItemType & Value (const Standard_Size theIndex) const
 Direct const access to the item. More...
 
const TheItemType & operator() (const Standard_Size theIndex) const
 Const access to the item - operator() More...
 
TheItemType & ChangeValue (const Standard_Size theIndex)
 Modification access to the item. More...
 
TheItemType & operator() (const Standard_Size theIndex)
 Access to the item - operator() More...
 
TheItemType & SetValue (const Standard_Size theIndex, const TheItemType &theValue)
 Set a value at specified index method. More...
 
DataMap-like interface
Standard_Size Extent () const
 Returns number of items in the array. More...
 
Standard_Boolean IsEmpty () const
 Returns True if array is empty. More...
 
const TheItemType & Find (const Standard_Size theIndex) const
 Direct const access to the item. More...
 
TheItemType & ChangeFind (const Standard_Size theIndex)
 Modification access to the item. More...
 
TheItemType & Bind (const Standard_Size theIndex, const TheItemType &theValue)
 Set a value as explicit method. More...
 
Standard_Boolean IsBound (const Standard_Size theIndex) const
 Returns True if the item is defined. More...
 
Standard_Boolean UnBind (const Standard_Size theIndex)
 Remove the item from array. More...
 
- Public Member Functions inherited from NCollection_SparseArrayBase
void Clear ()
 Clears all the data. More...
 
Standard_Size Size () const
 Returns number of currently contained items. More...
 
Standard_Boolean HasValue (const Standard_Size theIndex) const
 Check whether the value at given index is set. More...
 
Standard_Boolean UnsetValue (const Standard_Size theIndex)
 Deletes the item from the array; returns True if that item was defined. More...
 

Additional Inherited Members

- Protected Member Functions inherited from NCollection_SparseArrayBase
 NCollection_SparseArrayBase (Standard_Size theItemSize, Standard_Size theBlockSize)
 Constructor; initialized by size of item and of block (in items) More...
 
virtual ~NCollection_SparseArrayBase ()
 Destructor. More...
 
Block getBlock (const Standard_Address theAddr) const
 Creates Block structure for block pointed by theAddr. More...
 
Standard_Address getItem (const Block &theBlock, Standard_Size theInd) const
 Find address of the item in the block by index (in the block) More...
 
Standard_Address getValue (const Standard_Size theIndex) const
 Direct const access to the item. More...
 
Standard_Address setValue (const Standard_Size theIndex, const Standard_Address theValue)
 Set a value to the specified item; returns address of the set item. More...
 
void assign (const NCollection_SparseArrayBase &theOther)
 Copy contents of theOther to this; assumes that this and theOther have exactly the same type of arguments. More...
 
void exchange (NCollection_SparseArrayBase &theOther)
 Exchange contents of theOther and this; assumes that this and theOther have exactly the same type of arguments. More...
 
- Protected Attributes inherited from NCollection_SparseArrayBase
Standard_Size myItemSize
 size of item More...
 
Standard_Size myBlockSize
 block size (in items) More...
 
Standard_Size myNbBlocks
 allocated size of blocks table More...
 
Standard_Size mySize
 number of currently defined items More...
 
Standard_AddressmyData
 array of pointers to data blocks More...
 

Detailed Description

template<class TheItemType>
class NCollection_SparseArray< TheItemType >

Dynamically resizable sparse array of objects

This class is similar to NCollection_Vector: it works like virtually unlimited array of items accessible by index; however unlike simple Vector it distinguishes items that have been set from the ones that have not been set explicitly.

This class can be also seen as equivalence of NCollection_DataMap<Standard_Integer,TheItemType> with the only one practical difference: it can be much less memory-expensive if items are small (e.g. Integer or Handle).

The index starts from 0, i.e. should be non-negative. Memory is allocated when item is set by SetValue().

Iterator returns only defined items; the item can be tested for being defined by IsSet(), and undefined by UnsetValue().

The attempt to access the item that has not been set will result in OutOfRange exception in Debug mode; in Release mode this will either return null-filled object or cause access violation.

Constructor & Destructor Documentation

◆ NCollection_SparseArray()

template<class TheItemType>
NCollection_SparseArray< TheItemType >::NCollection_SparseArray ( Standard_Size  theIncrement)
inlineexplicit

Constructor; accepts size of blocks.

◆ ~NCollection_SparseArray()

template<class TheItemType>
virtual NCollection_SparseArray< TheItemType >::~NCollection_SparseArray ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ Assign()

template<class TheItemType>
NCollection_SparseArray& NCollection_SparseArray< TheItemType >::Assign ( const NCollection_SparseArray< TheItemType > &  theOther)
inline

Explicit assignment operator.

◆ Bind()

template<class TheItemType>
TheItemType& NCollection_SparseArray< TheItemType >::Bind ( const Standard_Size  theIndex,
const TheItemType &  theValue 
)
inline

Set a value as explicit method.

◆ ChangeFind()

template<class TheItemType>
TheItemType& NCollection_SparseArray< TheItemType >::ChangeFind ( const Standard_Size  theIndex)
inline

Modification access to the item.

◆ ChangeValue()

template<class TheItemType>
TheItemType& NCollection_SparseArray< TheItemType >::ChangeValue ( const Standard_Size  theIndex)
inline

Modification access to the item.

◆ Exchange()

template<class TheItemType>
void NCollection_SparseArray< TheItemType >::Exchange ( NCollection_SparseArray< TheItemType > &  theOther)
inline

Exchange the data of two arrays; can be used primarily to move contents of theOther into the new array in a fast way (without creation of duplicated data)

◆ Extent()

template<class TheItemType>
Standard_Size NCollection_SparseArray< TheItemType >::Extent ( ) const
inline

Returns number of items in the array.

◆ Find()

template<class TheItemType>
const TheItemType& NCollection_SparseArray< TheItemType >::Find ( const Standard_Size  theIndex) const
inline

Direct const access to the item.

◆ IsBound()

template<class TheItemType>
Standard_Boolean NCollection_SparseArray< TheItemType >::IsBound ( const Standard_Size  theIndex) const
inline

Returns True if the item is defined.

◆ IsEmpty()

template<class TheItemType>
Standard_Boolean NCollection_SparseArray< TheItemType >::IsEmpty ( ) const
inline

Returns True if array is empty.

◆ operator()() [1/2]

template<class TheItemType>
const TheItemType& NCollection_SparseArray< TheItemType >::operator() ( const Standard_Size  theIndex) const
inline

Const access to the item - operator()

◆ operator()() [2/2]

template<class TheItemType>
TheItemType& NCollection_SparseArray< TheItemType >::operator() ( const Standard_Size  theIndex)
inline

Access to the item - operator()

◆ SetValue()

template<class TheItemType>
TheItemType& NCollection_SparseArray< TheItemType >::SetValue ( const Standard_Size  theIndex,
const TheItemType &  theValue 
)
inline

Set a value at specified index method.

◆ UnBind()

template<class TheItemType>
Standard_Boolean NCollection_SparseArray< TheItemType >::UnBind ( const Standard_Size  theIndex)
inline

Remove the item from array.

◆ Value()

template<class TheItemType>
const TheItemType& NCollection_SparseArray< TheItemType >::Value ( const Standard_Size  theIndex) const
inline

Direct const access to the item.


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