CmpStr - v3.2.1
    Preparing search index...

    Class Pool

    The Pool class provides a buffer pool for dynamic programming algorithms.

    It allows for efficient reuse of buffers (Int32Array, number[], Set, Map) to reduce memory allocations and garbage collection overhead.

    Index

    Constructors

    Properties

    CONFIG: Record<PoolType, PoolConfig> = ...

    Pool Types

    POOLS: Record<PoolType, RingPool<any>> = ...

    Pool Rings for each type

    Methods

    • Acquires a buffer of the specified type and size from the pool. If no suitable buffer is available, it allocates a new one.

      Type Parameters

      • T = any

      Parameters

      • type: PoolType

        The type of buffer to acquire (e.g., 'int32', 'number[]', 'map')

      • size: number

        The size of the buffer to acquire

      Returns T

      • The acquired buffer of the specified type
    • Acquires multiple buffers of the specified type and sizes from the pool.

      Type Parameters

      • T = any

      Parameters

      • type: PoolType

        The type of buffers to acquire

      • sizes: number[]

        An array of sizes for each buffer to acquire

      Returns T[]

      • An array of acquired buffers of the specified type
    • Allocates a new buffer of the specified type and size.

      Parameters

      • type: PoolType

        The type of buffer to allocate

      • size: number

        The size of the buffer to allocate

      Returns any

      • The newly allocated buffer
    • Releases a buffer back to the pool. If the size of the buffer is larger than the maximum item size, it will not be released.

      Type Parameters

      • T = any

      Parameters

      • type: PoolType

        The type of buffer to release

      • buffer: T

        The buffer to release

      • size: number

        The size of the buffer

      Returns void