FlatQueue constructor

FlatQueue({
  1. int? initialCapacity,
  2. double? growthRate,
})

Creates an empty minimum priority queue.

May optionally specify an initialCapacity and growthRate. Setting an initialCapacity can reduce the number of memory allocations needed when adding elements to the queue, and growthRate can be used to control how much the queue grows when it runs out of capacity, which additionally can reduce the number of memory allocations needed. For tuning algorithms, it's recommended to set initialCapacity to the expected number of elements in the queue, and growthRate to a value greater than 1.0 (which is the default).

Example

final queue = FlatQueue(initialCapacity: 100, growthRate: 1.5);

Implementation

FlatQueue({
  int? initialCapacity,
  double? growthRate,
})  : _ids = Uint32List(initialCapacity ?? 16),
      _priorities = Float32List(initialCapacity ?? 16),
      _growthRate = growthRate ?? 1.0;