OpenCascade.js
API ReferenceFoundationClassesTKernel

NCollection

OCCT package NCollection: NCollection_AccAllocator, NCollection_AlignedAllocator, NCollection_BaseAllocator, NCollection_BaseList, and 16 more bound classes.

NCollection_AccAllocator

Class NCollection_AccAllocator - accumulating memory allocator. This class allocates memory on request returning the pointer to the allocated space. The allocation units are grouped in blocks requested from the system as required. This memory is returned to the system when all allocations in a block are freed.
By comparison with the standard new() and malloc() calls, this method is faster and consumes very small additional memory to maintain the heap.
By comparison with NCollection_IncAllocator, this class requires some more additional memory and a little more time for allocation and deallocation. Memory overhead for NCollection_IncAllocator is 12 bytes per block; average memory overhead for NCollection_AccAllocator is 28 bytes per block.
All pointers returned by Allocate() are aligned to 4 byte boundaries. To define the sizeof memory blocks requested from the OS, use the parameter of the constructor (measured in bytes).

Constructors(1)

Static methods(2)

Instance methods(1)

NCollection_BaseAllocator

Purpose: Basic class for memory allocation wizards. Defines the interface for devising different allocators firstly to be used by collections of NCollection, though it it is not deferred. It allocates/frees the memory through Standard procedures, thus it is unnecessary (and sometimes injurious) to have more than one such allocator. To avoid creation of multiple objects the constructors were maid inaccessible. To create the BaseAllocator use the method CommonBaseAllocator. Note that this object is managed by Handle.

Static methods(3)

Instance methods(1)

NCollection_BaseMap

Purpose: This is a base class for all Maps: Map DataMap DoubleMap IndexedMap IndexedDataMap Provides utilitites for managing the buckets.

Instance methods(5)

  • Extent(): number

    Extent (number of elements, legacy int-returning API).

  • Length(): number

    Length - number of elements (legacy int-returning API, synonym of Extent()).

  • Size(): number

    Size - number of elements.

  • IsEmpty(): boolean

    IsEmpty.

  • Returns attached allocator.

NCollection_Buffer

Low-level buffer object.

Constructors(1)

  • constructor(theAlloc: NCollection_BaseAllocator, theSize?: number, theData?: number): NCollection_Buffer

    Default constructor. When theData is NULL but theSize is not 0 than buffer of specified size will be allocated.

    Parameters (3)
    • theAlloc
      memory allocator
    • theSize
      buffer size
    • theData
      buffer data allocated by theAlloc

Static methods(2)

Instance methods(9)

NCollection_IncAllocator

Class NCollection_IncAllocator - incremental memory allocator. This class allocates memory on request returning the pointer to an allocated block. This memory is never returned to the system until the allocator is destroyed.
By comparison with the standard new() and malloc() calls, this method is faster and consumes very small additional memory to maintain the heap.
All pointers returned by Allocate() are aligned to the size of the data type "aligned_t". To modify the size of memory blocks requested from the OS, use the parameter of the constructor (measured in bytes); if this parameter is smaller than 25 bytes on 32bit or 49 bytes on 64bit, the block size will be the default 12 kbytes.
It is not recommended to use memory blocks larger than 16KB on Windows platform for the repeated operations because Low Fragmentation Heap is not going to be used for these allocations which may lead to memory fragmentation and the general performance slow down.
Note that this allocator is most suitable for single-threaded algorithms (consider creating dedicated allocators per working thread), and thread-safety of allocations is DISABLED by default (see SetThreadSafe()).

Constructors(1)

  • constructor(theBlockSize?: number): NCollection_IncAllocator

    Constructor. Note that this constructor does NOT setup mutex for using allocator concurrently from different threads, see SetThreadSafe() method.
    The default size of the memory blocks is 12KB. It is not recommended to use memory blocks larger than 16KB on Windows platform for the repeated operations (and thus multiple allocations) because Low Fragmentation Heap is not going to be used for these allocations, leading to memory fragmentation and eventual performance slow down.

    Parameters (1)
    • theBlockSize

Static methods(2)

Instance methods(3)

  • SetThreadSafe(theIsThreadSafe?: boolean): void

    Setup mutex for thread-safe allocations.

    Parameters (1)
    • theIsThreadSafe
    Remarks

    Warning: Must not be called concurrently with Allocate/AllocateOptimal/Reset/clean on the same allocator instance; toggling the mutex while another thread holds a shared_lock on the fast path is undefined behaviour.

  • Reset(theReleaseMemory?: boolean): void

    Re-initialize the allocator so that the next Allocate call should start allocating in the very beginning as though the allocator is just constructed. Warning: make sure that all previously allocated data are no more used in your code!

    Parameters (1)
    • theReleaseMemory
      True - release all previously allocated memory, False - preserve it for future allocations.

NCollection_SparseArrayBase

Base class for NCollection_SparseArray; provides non-template implementation of general mechanics of block allocation, items creation / deletion etc.
Type-specific item operations (construction, destruction, copy) are provided by the derived template class via function pointers passed as arguments to the protected methods.

Instance methods(2)

  • Size(): number
  • HasValue(theIndex: number): boolean
    Parameters (1)
    • theIndex

NCollection_String

This template class represent constant UTF-* string. String stored in memory continuously, always NULL-terminated and can be used as standard C-string using ToCString() method.
Notice that changing the string is not allowed and any modifications should produce new string.
In comments to this class, terms "Unicode symbol" is used as synonym of "Unicode code point".

Constructors(3)

Instance methods(17)

  • Size(): number
    Returns

    the size of the buffer in bytes, excluding NULL-termination symbol

  • Length(): number
    Returns

    the length of the string in Unicode symbols

  • GetChar(theCharIndex: number): string

    Retrieve Unicode symbol at specified position. Warning! This is a slow access. Iterator should be used for consecutive parsing.

    Parameters (1)
    • theCharIndex
      the index of the symbol, should be lesser than Length()
    Returns

    the Unicode symbol value

  • GetCharBuffer(theCharIndex: number): string

    Retrieve string buffer at specified position. Warning! This is a slow access. Iterator should be used for consecutive parsing.

    Parameters (1)
    • theCharIndex
      the index of the symbol, should be less than Length() (first symbol of the string has index 0)
    Returns

    the pointer to the symbol

  • FromLocale(theString: string, theLength?: number): void

    Copy from multibyte string in current system locale.

    Parameters (2)
    • theString
      multibyte string
    • theLength
      the length limit in Unicode symbols The string is copied till NULL symbol or, if theLength >0, till either NULL or theLength-th symbol (which comes first).
  • IsEqual(theCompare: NCollection_String): boolean

    Compares this string with another one.

    Parameters (1)
    • theCompare
  • SubString(theStart: number, theEnd: number): NCollection_String

    Returns the substring.

    Parameters (2)
    • theStart
      start index (inclusive) of subString
    • theEnd
      end index (exclusive) of subString
    Returns

    the substring

  • ToCString(): string

    Returns NULL-terminated Unicode string. Should not be modified or deleted!

    Returns

    (const Type* ) pointer to string

  • ToUtf8(): string
    Returns

    copy in UTF-8 format

  • ToUtf16(): string
    Returns

    copy in UTF-16 format

  • ToUtf32(): string
    Returns

    copy in UTF-32 format

  • ToUtfWide(): string
    Returns

    copy in wide format (UTF-16 on Windows and UTF-32 on Linux)

  • ToLocale(theBuffer: string, theSizeBytes: number): boolean

    Converts the string into string in the current system locale.

    Parameters (2)
    • theBuffer
      output buffer
    • theSizeBytes
      buffer size in bytes
    Returns

    true on success

  • IsEmpty(): boolean
    Returns

    true if string is empty

  • Clear(): void

    Zero string.

  • Parameters (1)
    • theOther
  • Swap(theOther: NCollection_String): void
    Parameters (1)
    • theOther

NCollection_WinHeapAllocator

This memory allocator creates dedicated heap for allocations. This technics available only on Windows platform (no alternative on Unix systems). It may be used to take control over memory fragmentation because on destruction ALL allocated memory will be released to the system.
This allocator can also be created per each working thread however its real multi-threading performance is dubious.
Notice that this also means that existing pointers will be broken and you should control that allocator is alive along all objects allocated with him.

Constructors(1)

Static methods(2)

Instance methods(1)