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)
- constructor(theBlockSize?: number): NCollection_AccAllocator
Constructor.
Parameters (1)theBlockSize
Static methods(2)
- get_type_name(): string
Instance methods(1)
NCollection_AlignedAllocator
NCollection allocator with managed memory alignment capabilities.
Constructors(1)
- constructor(theAlignment: number): NCollection_AlignedAllocator
Constructor. The alignment should be specified explicitly: 16 bytes for SSE instructions 32 bytes for AVX instructions.
Parameters (1)theAlignment
Static methods(2)
- get_type_name(): string
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)
CommonBaseAllocator This method is designed to have the only one BaseAllocator (to avoid useless copying of collections). However one can use operator new to create more BaseAllocators, but it is injurious.
- get_type_name(): string
Instance methods(1)
NCollection_BaseList
Instance methods(4)
NCollection_BaseList_Iterator
Constructors(2)
- Parameters (1)
theList
Instance methods(2)
- Initialize(theList: NCollection_BaseList): voidParameters (1)
theList
- More(): boolean
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)
NCollection_BaseMap_Iterator
Instance methods(2)
- Initialize(theMap: NCollection_BaseMap): voidParameters (1)
theMap
- Reset(): void
NCollection_BaseSequence
Purpose: This is a base class for the Sequence. It deals with an indexed bidirectional list of NCollection_SeqNode's.
Instance methods(3)
NCollection_BaseSequence_Iterator
Constructors(2)
- constructor(theSeq: NCollection_BaseSequence, isStart: boolean): NCollection_BaseSequence_IteratorParameters (2)
theSeqisStart
Instance methods(2)
- Init(theSeq: NCollection_BaseSequence, isStart?: boolean): voidParameters (2)
theSeqisStart
- Previous(): void
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 allocatortheSize—buffer sizetheData—buffer data allocated by theAlloc
Static methods(2)
- get_type_name(): string
Instance methods(9)
- Data(): numberReturns
buffer data
- ChangeData(): numberReturns
buffer data
- IsEmpty(): booleanReturns
true if buffer is not allocated
- Size(): number
Return buffer length in bytes.
- Returns
buffer allocator
- SetAllocator(theAlloc: NCollection_BaseAllocator): void
Assign new buffer allocator with de-allocation of buffer.
Parameters (1)theAlloc
- Allocate(theSize: number): boolean
Allocate the buffer.
Parameters (1)theSize—buffer length in bytes
- Free(): void
De-allocate buffer.
NCollection_CellFilter_Action
Properties(2)
NCollection_ForwardRangeSentinel
Empty sentinel type used as the end marker for range-for loops.
Constructors(1)
NCollection_HeapAllocator
Allocator that uses the global dynamic heap (malloc / free).
Static methods(3)
- get_type_name(): string
Instance methods(1)
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)
- get_type_name(): string
Instance methods(3)
- SetThreadSafe(theIsThreadSafe?: boolean): void
Setup mutex for thread-safe allocations.
Parameters (1)theIsThreadSafe
RemarksWarning: 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_IncAllocator_IBlock
Properties(2)
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)
NCollection_SparseArrayBase_Iterator
Instance methods(4)
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)
Initialize empty string.
- constructor(theCopy: NCollection_String): NCollection_String
Copy constructor.
Parameters (1)theCopy—string to copy.
- constructor(theCopyUtf8: string, theLength?: number): NCollection_String
Copy constructor from UTF-8 string.
Parameters (2)theCopyUtf8—UTF-8 string to copytheLength—optional length limit in Unicode symbols (NOT bytes!) The string is copied till NULL symbol or, if theLength >0, till either NULL or theLength-th symbol (which comes first).
Instance methods(17)
- Size(): numberReturns
the size of the buffer in bytes, excluding NULL-termination symbol
- Length(): numberReturns
the length of the string in Unicode symbols
- GetChar(theCharIndex: number): string
Retrieve Unicode symbol at specified position. Warning! This is a slow access.
Iteratorshould be used for consecutive parsing.Parameters (1)theCharIndex—the index of the symbol, should be lesser thanLength()
Returnsthe Unicode symbol value
- GetCharBuffer(theCharIndex: number): string
Retrieve string buffer at specified position. Warning! This is a slow access.
Iteratorshould be used for consecutive parsing.Parameters (1)theCharIndex—the index of the symbol, should be less thanLength()(first symbol of the string has index 0)
Returnsthe pointer to the symbol
- FromLocale(theString: string, theLength?: number): void
Copy from multibyte string in current system locale.
Parameters (2)theString—multibyte stringtheLength—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 subStringtheEnd—end index (exclusive) of subString
Returnsthe substring
- ToCString(): string
Returns NULL-terminated Unicode string. Should not be modified or deleted!
Returns(const Type* ) pointer to string
- ToUtf8(): stringReturns
copy in UTF-8 format
- ToUtf16(): stringReturns
copy in UTF-16 format
- ToUtf32(): stringReturns
copy in UTF-32 format
- ToUtfWide(): stringReturns
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 buffertheSizeBytes—buffer size in bytes
Returnstrue on success
- IsEmpty(): booleanReturns
true if string is empty
- Clear(): void
Zero string.
- Assign(theOther: NCollection_String): NCollection_StringParameters (1)
theOther
- Swap(theOther: NCollection_String): voidParameters (1)
theOther
NCollection_UtfStringTool
Constructors(1)
Static methods(1)
- ToLocale(theWideString: string, theBuffer: string, theSizeBytes: number): booleanParameters (3)
theWideStringtheBuffertheSizeBytes
Instance methods(1)
- FromLocale(theString: string): stringParameters (1)
theString
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)
- constructor(theInitSizeBytes?: number): NCollection_WinHeapAllocator
Main constructor.
Parameters (1)theInitSizeBytes
Static methods(2)
- get_type_name(): string