Skip to content

[alloc + set] Introducing BStackChunk API with sorting and iterator - #38

Merged
williamwutq merged 8 commits into
masterfrom
slice
Aug 8, 2026
Merged

[alloc + set] Introducing BStackChunk API with sorting and iterator#38
williamwutq merged 8 commits into
masterfrom
slice

Conversation

@williamwutq

Copy link
Copy Markdown
Owner

Description: Adding BStackChunk<'a> with its iterator BStackChunkIter<'a> — fixed-stride view over BStackSlice. It holds the same semantic position as BStackSlice<'a> and offers additional atomic search/sort/select APIs (binary_search_by/binary_search_by_key/sort_by/sort_by_key/select_nth_by/select_nth_by_key).

New Feature: Yes
Important Feature: Yes
Feature Flags: alloc (+ set + atomic)
Breaking change: No
New Types: BStackChunk and BStackChunkIter
Rust Only: Yes
Fuzz: Not needed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new fixed-stride “record view” abstraction (BStackChunk<'a>) over BStackSlice, plus a lazy iterator (BStackChunkIter<'a>), enabling chunk-oriented iteration and APIs like binary search, stable sorting, and selection on whole records.

Changes:

  • Introduces BStackChunk/BStackChunkIter with chunks/rchunks constructors (and owned-slice mirrors), iteration, and view utilities (get, as_slice, into_slice, with_stride).
  • Adds chunk-level algorithms: binary_search_by(_key) (alloc-only) and sort_by(_key) / select_nth_by(_key) (gated behind set + atomic).
  • Expands tests and documentation (README/CHANGELOG), and updates the roadmap (PLANNED.md) to reflect the implemented strategy and future work.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/alloc/chunk.rs New BStackChunk / BStackChunkIter implementation, chunking constructors on BStackSlice, and chunk algorithms.
src/alloc/mod.rs Wires in the new chunk module and re-exports the new types.
src/lib.rs Re-exports BStackChunk and BStackChunkIter from the crate’s public API.
src/test.rs Adds unit tests covering construction, remainder behavior, iteration, sorting, searching, selection, and trait semantics.
README.md Documents the new types, trait semantics, and the chunked-view API surface.
CHANGELOG.md Adds release notes describing the new BStackChunk API and behavior/traits.
PLANNED.md Updates the design notes to focus on future external-merge-sort and out-of-core selection strategies for chunks.
Suppressed comments (1)

src/alloc/chunk.rs:567

  • ExactSizeIterator requires that len() be exact, but for BStackChunkIter the number of remaining chunks is derived from a u64 length and can exceed what fits in usize on 32-bit platforms. With the current implementation this can silently truncate via size_hint and violate the ExactSizeIterator contract. Consider only implementing ExactSizeIterator where it is always representable (e.g. gate it on 64-bit pointer width) or remove the impl.
impl<'a> ExactSizeIterator for BStackChunkIter<'a> {}

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/alloc/chunk.rs
Comment thread src/alloc/chunk.rs Outdated
Comment thread src/test.rs
Comment thread README.md Outdated
Comment thread CHANGELOG.md
@williamwutq
williamwutq merged commit 77c9173 into master Aug 8, 2026
16 checks passed
@williamwutq
williamwutq deleted the slice branch August 8, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants