radix_plus library

radix_Plus

⚑ A high-performance, parallelized Radix Sort library for Dart.

radix_Plus brings native-like speed to Dart’s sorting world. It’s designed for developers who need maximum performance, low GC pressure, and fine-grained control over memory and threading.

πŸš€ Core Highlights

  • Multi-Type Sorting: Supports List<int>, List<double>, and List<BigInt>.
  • Stable & Accurate: Preserves order of equal elements and correctly handles signed values, Β±0, ±∞, and NaN.
  • TypedData Optimized: Works directly with Int32List, Uint32List, and Float64List for zero-copy performance.
  • Parallel Execution: Leverages Isolates for large-scale data sorting.
  • Adaptive Hybrid Logic: Automatically switches to insertion sort for small segments to minimize overhead.

🧠 Advanced Capabilities

  • Buffer Pooling: Reuse pre-allocated buffers to reduce GC overhead.
  • Range Optimization: Specialized BigInt routines with maxBitLength hints.
  • Custom Merge Strategies: Control parallel merge behavior for massive datasets.
  • Performance Estimation: Benchmark potential speedups with estimateParallelPerformance().

🧰 API Overview

Function Description
radixSortInt() Sorts any List<int> (signed/unsigned).
radixSortDouble() Stable sort for doubles (handles ±∞, NaN).
radixSortBigInt() Hybrid Radix Sort for arbitrary precision integers.
radixSortFloat64() Zero-copy sorting for Float64List.
radixSortParallelUnsigned() Multi-core sorting for large unsigned integer lists.
clearBufferPools() Frees all global buffer pools to release memory.

βš™οΈ Example

import 'package:radix_Plus/radix_Plus.dart';

void main() {
  final data = List.generate(1000000, (i) => 1000000 - i);

  // High-performance parallel radix sort
  await radixSortParallelUnsigned(data);

  print(data.take(10));
}

Functions

clearBufferPools() β†’ void
A top-level function to clear all global buffer pools.
radixSortBigInt(List<BigInt> data, {bool ascending = true}) β†’ void
Sorts a list of BigInts in place using a highly optimized, hybrid Radix Sort.
radixSortBigIntWithRange(List<BigInt> data, {required int maxBitLength, bool ascending = true}) β†’ void
Sorts a list of BigInts with range optimization.
radixSortDouble(List<double> data, {bool ascending = true, bool reuseBuffer = true}) β†’ void
Sorts a list of doubles in place using a stable Radix Sort.
radixSortFloat64(Float64List data, {bool ascending = true, bool reuseBuffer = true}) β†’ void
Advanced version that works directly with Float64List for maximum performance.
radixSortFloat64WithNaN(Float64List data, {bool ascending = true, String nanPlacement = 'end', bool reuseBuffer = true}) β†’ void
Sorts a list of doubles with NaN handling options.
radixSortInt(List<int> data, {bool signed = true, bool ascending = true, int bitsPerPass = 8, bool stable = true, bool reuseBuffer = true}) β†’ void
Sorts a list of integers in place using a stable Radix Sort.
radixSortInt32(Int32List data, {bool ascending = true, bool reuseBuffer = true}) β†’ void
Advanced version that works with pre-allocated typed lists for maximum performance.
radixSortParallelSigned(List<int> data, {int? threads}) β†’ Future<void>
radixSortParallelUnsigned(List<int> data, {int? threads}) β†’ Future<void>
radixSortUint32(Uint32List data, {bool ascending = true, bool reuseBuffer = true}) β†’ void
Advanced version for unsigned 32-bit integers with zero-copy when possible.