Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-place merge sort for slices #248

Merged
merged 9 commits into from
Nov 19, 2024
Merged

In-place merge sort for slices #248

merged 9 commits into from
Nov 19, 2024

Conversation

tahina-pro
Copy link
Member

This PR reorganizes the implementations of in-place merge sort:

  • It renames Pulse.Lib.ArraySwap into Pulse.Lib.Swap.Array (cf. Swapping two adjacent regions of an array of any sizes steel#12)
  • It introduces Pulse.Lib.Swap.Slice to swap the contents of two adjacent regions within a slice
  • It renames Pulse.Lib.Array.MergeSort into Pulse.Lib.Sort.Merge.Array (cf. In-place array merge sort #245 )
  • It introduces Pulse.Lib.Sort.Merge.Slice to sort the contents of a slice using in-place merge sort. (Like the array implementation, it is optimized for memory consumption rather than speed.)

@tahina-pro tahina-pro marked this pull request as ready for review November 9, 2024 09:03
@tahina-pro
Copy link
Member Author

This PR also marks the element type argument of Pulse.Lib.ArrayPtr.ptr and Pulse.Lib.Slice.slice strictly positive. This is needed to use slices in recursive type definitions.

tahina-pro added a commit to project-everest/everparse that referenced this pull request Nov 9, 2024
@tahina-pro tahina-pro requested a review from gebner November 11, 2024 06:30
@tahina-pro tahina-pro marked this pull request as draft November 15, 2024 18:35
@tahina-pro tahina-pro marked this pull request as ready for review November 18, 2024 23:50
@tahina-pro
Copy link
Member Author

There should be a way to make the sorting function constant stack space, by avoiding recursion and walking through the array/slice to merge adjacent subslices instead, but I'll do that in a separate PR

@tahina-pro tahina-pro merged commit 7f20441 into main Nov 19, 2024
1 check passed
tahina-pro added a commit to project-everest/everparse that referenced this pull request Nov 19, 2024
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.

1 participant