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

Mutable dynamic arrays, heaps, and simple union find data structures #585

Merged
merged 13 commits into from
Jan 27, 2025

Conversation

marzipankaiser
Copy link
Contributor

For writing examples, I wanted to have some standard mutable data structures, currently:

  • dynamic/resizable arrays
  • min-heap (=> priority queue)
  • union-find on integers

They all still need more documentation, testing and maybe some additional functions (I only implemented what I needed).

Copy link
Contributor

@jiribenes jiribenes left a comment

Choose a reason for hiding this comment

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

Looks good so far!
I had some time during the meeting, so I quickly wrote some observations. :)

libraries/common/heap.effekt Outdated Show resolved Hide resolved
libraries/common/resizable_array.effekt Outdated Show resolved Hide resolved
libraries/common/resizable_array.effekt Outdated Show resolved Hide resolved
libraries/common/resizable_array.effekt Outdated Show resolved Hide resolved
libraries/common/resizable_array.effekt Outdated Show resolved Hide resolved
libraries/common/union_find.effekt Outdated Show resolved Hide resolved
@b-studios
Copy link
Collaborator

What happened to this PR, it looks really cool! :)

@marzipankaiser
Copy link
Contributor Author

@b-studios Mostly I didn't get around to doing much here since. The code is tested as far as the tests here go (so not much), but should mostly work (TM).
I'd like to do some cleanup before merging (e.g. we do have doc-comments now...)

@marzipankaiser marzipankaiser force-pushed the feature/stdlib/mutable-darray-heap-uf branch 2 times, most recently from dc62953 to 597bded Compare November 5, 2024 14:41
@marzipankaiser
Copy link
Contributor Author

Rebased, cleaned up a bit. Should be fine, except not tested well and not documented in too much detail, either.

@marzipankaiser marzipankaiser changed the title [WIP] Mutable dynamic arrays, heaps, and simple union find data structures Mutable dynamic arrays, heaps, and simple union find data structures Nov 5, 2024
@marzipankaiser marzipankaiser force-pushed the feature/stdlib/mutable-darray-heap-uf branch from 45b9185 to 88c4f5e Compare January 27, 2025 08:50
@marzipankaiser
Copy link
Contributor Author

Rebased to check if the Valgrind-issues happen to be fixed by now.

@marzipankaiser marzipankaiser marked this pull request as ready for review January 27, 2025 09:30
/// find and remove the minimal element in this heap
///
/// O(log n)
def deleteMin[T](heap: Heap[T]): T / Exception[OutOfBounds] = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bike shed, in the comment you write "remove" but the function is called deleteMin. Some languages also call this operation pop (and insert then push):

https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose the names based on what https://en.wikipedia.org/wiki/Binary_heap calls the operations, but we can rename them - I don't have a strong opinion here.

libraries/common/resizable_array.effekt Show resolved Hide resolved
@jiribenes
Copy link
Contributor

🪤 It could be fun to take the unification benchmark from other/unify and try it with the union find from this PR.

@b-studios b-studios merged commit e6a82e2 into master Jan 27, 2025
3 checks passed
@b-studios b-studios deleted the feature/stdlib/mutable-darray-heap-uf branch January 27, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants