Nucleoc::Boxcar(T)
Inspired by Rust's boxcar::Vec, adapted for Crystal native concurrency.
A concurrent, append-only vector that supports parallel appends and random access. Uses atomic operations for thread-safe indexing and Crystal's native spawn for parallelism.
Constants
Default bucket size (power of two for fast division).
Maximum number of buckets before resizing.
Constructors
Instance methods
Get value at index, or nil if not yet initialized or out of bounds.
Get entry at index, or nil if not yet initialized or out of bounds.
Process elements in parallel, applying a block to each. Returns an array of results in the same order as elements.
Process elements in parallel, applying a block to each and collecting non-nil results.
Append a single value with column data.
Append multiple values efficiently with column data. Uses native Crystal spawn for parallel appends if beneficial.
Append multiple values without column data (for testing).
Sort snapshot with comparator.
Get top K elements from snapshot using comparator. More efficient than full sort when k << n. The comparator should return: negative if a < b zero if a == b positive if a > b For top-k largest elements, use standard <=> comparator. For top-k smallest elements, use reversed comparator.