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

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

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
Comment on lines 9 to 16
// These numbers should be optimized based on benchmarking
// According to https://en.wikipedia.org/wiki/Dynamic_array most use 1.5 or 2
//
// Factor by which to grow the capacity when it becomes too small
val growFactor = 1.5
// shrink array when size / capacity falls below this threshold
// should be < 1/growFactor
val shrinkThreshold = 0.4
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this requires #496 in order to work on LLVM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I know 😢

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 from 72702b3 to 48bfc57 Compare November 5, 2024 14:36
@marzipankaiser marzipankaiser force-pushed the feature/stdlib/mutable-darray-heap-uf branch 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
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