OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    NCollection_SparseArray< TheItemType > Class Template Reference

    #include <NCollection_SparseArray.hxx>

    Inheritance diagram for NCollection_SparseArray< TheItemType >:

    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

    Detailed Description

    template<class TheItemType>
    class NCollection_SparseArray< TheItemType >

    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.

    Constructor & Destructor Documentation

    ◆ NCollection_SparseArray()

    template<class TheItemType>
    NCollection_SparseArray< TheItemType >::NCollection_SparseArray ( size_t theIncrement)
    inlineexplicitnoexcept

    Constructor; accepts size of blocks.

    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 size_t theIndex,
    const TheItemType & theValue )
    inline

    Set a value as explicit method.

    ◆ ChangeFind()

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

    Modification access to the item.

    ◆ ChangeValue()

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

    Modification access to the item.

    ◆ Clear()

    template<class TheItemType>
    void NCollection_SparseArray< TheItemType >::Clear ( )
    inline

    Clears all the data.

    ◆ Exchange()

    template<class TheItemType>
    void NCollection_SparseArray< TheItemType >::Exchange ( NCollection_SparseArray< TheItemType > & theOther)
    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).

    ◆ Extent()

    template<class TheItemType>
    size_t NCollection_SparseArray< TheItemType >::Extent ( ) const
    inlinenoexcept

    Returns number of items in the array.

    ◆ Find()

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

    Direct const access to the item.

    ◆ IsBound()

    template<class TheItemType>
    bool NCollection_SparseArray< TheItemType >::IsBound ( const size_t theIndex) const
    inline

    Returns True if the item is defined.

    ◆ IsEmpty()

    template<class TheItemType>
    bool NCollection_SparseArray< TheItemType >::IsEmpty ( ) const
    inlinenoexcept

    Returns True if array is empty.

    ◆ operator()() [1/2]

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

    Access to the item - operator().

    ◆ operator()() [2/2]

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

    Const access to the item - operator().

    ◆ SetValue()

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

    Set a value at specified index method.

    ◆ UnBind()

    template<class TheItemType>
    bool NCollection_SparseArray< TheItemType >::UnBind ( const size_t theIndex)
    inline

    Remove the item from array.

    ◆ UnsetValue()

    template<class TheItemType>
    bool NCollection_SparseArray< TheItemType >::UnsetValue ( const size_t theIndex)
    inline

    Deletes the item from the array; returns True if that item was defined.

    ◆ Value()

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

    Direct const access to the item.


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