CmpStr - v3.4.0
    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
    CONFIG: Record<PoolType, PoolConfig> = ...

    Pool Types

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

    Pool Rings for each type

    • 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 = unknown

        The type of the buffer to acquire

      Parameters

      • type: PoolType

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

      • size: number

        The size of the buffer to acquire

      Returns Buffer<T>

      • The acquired buffer of the specified type
      • Throws an error if the pool type is unsupported
    • Acquires multiple buffers of the specified type and sizes from the pool.

      Type Parameters

      • T = unknown

        The type of the buffers to acquire

      Parameters

      • type: PoolType

        The type of buffers to acquire

      • sizes: number[]

        An array of sizes for each buffer to acquire

      Returns Buffer<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[]
          | Int32Array<ArrayBuffer>
          | Float64Array<ArrayBuffer>
          | Map<any, any>
          | Set<unknown>

      • 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 = unknown

        The type of the buffer being released

      Parameters

      • type: PoolType

        The type of buffer to release

      • buffer: Buffer<T>

        The buffer to release

      Returns void

      • Throws an error if the pool type is unsupported