![]() |
Open CASCADE Technology Reference Manual 8.0.0
|
#include <NCollection_SparseArray.hxx>

Data Structures | |
| class | ConstIterator |
| class | Iterator |
Public Member Functions | |
| NCollection_SparseArray (size_t theIncrement) noexcept | |
| Constructor; accepts size of blocks. | |
| NCollection_SparseArray & | Assign (const NCollection_SparseArray &theOther) |
| Explicit assignment operator. | |
| void | Exchange (NCollection_SparseArray &theOther) noexcept |
| 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) | |
| void | Clear () |
| Clears all the data. | |
Array-like interface (in addition to inherited methods) | |
| const TheItemType & | Value (const size_t theIndex) const |
| Direct const access to the item. | |
| const TheItemType & | operator() (const size_t theIndex) const |
| Const access to the item - operator() | |
| TheItemType & | ChangeValue (const size_t theIndex) |
| Modification access to the item. | |
| TheItemType & | operator() (const size_t theIndex) |
| Access to the item - operator() | |
| TheItemType & | SetValue (const size_t theIndex, const TheItemType &theValue) |
| Set a value at specified index method. | |
| bool | UnsetValue (const size_t theIndex) |
| Deletes the item from the array; returns True if that item was defined. | |
DataMap-like interface | |
| size_t | Extent () const noexcept |
| Returns number of items in the array. | |
| bool | IsEmpty () const noexcept |
| Returns True if array is empty. | |
| const TheItemType & | Find (const size_t theIndex) const |
| Direct const access to the item. | |
| TheItemType & | ChangeFind (const size_t theIndex) |
| Modification access to the item. | |
| TheItemType & | Bind (const size_t theIndex, const TheItemType &theValue) |
| Set a value as explicit method. | |
| bool | IsBound (const size_t theIndex) const |
| Returns True if the item is defined. | |
| bool | UnBind (const size_t theIndex) |
| Remove the item from array. | |
Public Member Functions inherited from NCollection_SparseArrayBase | |
| size_t | Size () const noexcept |
| Returns number of currently contained items. | |
| bool | HasValue (const size_t theIndex) const |
| Check whether the value at given index is set. | |
Additional Inherited Members | |
Public Types inherited from NCollection_SparseArrayBase | |
| using | CreateItemFunc = void (*)(void* theAddress, void* theOther) |
| Copy-construct a new item at theAddress from theOther. | |
| using | DestroyItemFunc = void (*)(void* theAddress) |
| Destroy the item at theAddress. | |
| using | CopyItemFunc = void (*)(void* theAddress, void* theOther) |
| Copy-assign the item at theAddress from theOther. | |
Protected Member Functions inherited from NCollection_SparseArrayBase | |
| NCollection_SparseArrayBase (size_t theItemSize, size_t theBlockSize, DestroyItemFunc theDestroyItem) noexcept | |
| Constructor; initialized by size of item, block size, and item destructor function. | |
| ~NCollection_SparseArrayBase () | |
| Destructor; properly destroys all items and frees all memory. Uses the stored DestroyItemFunc, so no virtual dispatch is needed. | |
| Block | getBlock (void *const theAddr) const noexcept |
| Creates Block structure for block pointed by theAddr. | |
| void * | getItem (const Block &theBlock, size_t theInd) const noexcept |
| Find address of the item in the block by index (in the block) | |
| void * | getValue (const size_t theIndex) const |
| Direct const access to the item. | |
| void | clearItems (DestroyItemFunc theDestroyItem) |
| Clears all items and frees all memory. | |
| bool | unsetValue (const size_t theIndex, DestroyItemFunc theDestroyItem) |
| Deletes the item at theIndex from the array; returns True if the item was defined. | |
| void * | setValue (const size_t theIndex, void *const theValue, CreateItemFunc theCreateItem, CopyItemFunc theCopyItem) |
| Set a value to the specified item; returns address of the set item. | |
| void | assign (const NCollection_SparseArrayBase &theOther, CreateItemFunc theCreateItem, DestroyItemFunc theDestroyItem, CopyItemFunc theCopyItem) |
| Copy contents of theOther to this; assumes that this and theOther have exactly the same type of arguments. | |
| void | exchange (NCollection_SparseArrayBase &theOther) noexcept |
| Exchange contents of theOther and this; assumes that this and theOther have exactly the same type of arguments. | |
Protected Attributes inherited from NCollection_SparseArrayBase | |
| size_t | myItemSize |
| size of item | |
| size_t | myBlockSize |
| block size (in items) | |
| size_t | myNbBlocks |
| allocated size of blocks table | |
| size_t | mySize |
| number of currently defined items | |
| void ** | myData |
| array of pointers to data blocks | |
| DestroyItemFunc | myDestroyItem |
| function to call destructor on items | |
Dynamically resizable sparse array of objects
This class is similar to NCollection_DynamicArray: 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<int,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.
|
inlineexplicitnoexcept |
Constructor; accepts size of blocks.
|
inline |
Explicit assignment operator.
|
inline |
Set a value as explicit method.
|
inline |
Modification access to the item.
|
inline |
Modification access to the item.
|
inline |
Clears all the data.
|
inlinenoexcept |
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)
|
inlinenoexcept |
Returns number of items in the array.
|
inline |
Direct const access to the item.
|
inline |
Returns True if the item is defined.
|
inlinenoexcept |
Returns True if array is empty.
|
inline |
Access to the item - operator()
|
inline |
Const access to the item - operator()
|
inline |
Set a value at specified index method.
|
inline |
Remove the item from array.
|
inline |
Deletes the item from the array; returns True if that item was defined.
|
inline |
Direct const access to the item.