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

Add Binary heap structure #5084

Merged
merged 38 commits into from
Jul 23, 2024
Merged

Add Binary heap structure #5084

merged 38 commits into from
Jul 23, 2024

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented Jun 16, 2024

Fixes #3410
Alternative to #5076

This PR uses names from https://en.wikipedia.org/wiki/Heap_(data_structure)#Operations

  • Basic
    • peek
    • insert
    • pop
    • replace
  • Internal
    • siftUp
    • siftDown

For the inspection part, we use length instead of size for consistencty with all other structures in the utils/struct folder.

PR Checklist

  • Tests
  • Tests Fuzzing
  • Documentation
  • Changeset entry (run npx changeset add)

Copy link

changeset-bot bot commented Jun 16, 2024

🦋 Changeset detected

Latest commit: 5b07512

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

.githooks/pre-push Outdated Show resolved Hide resolved
@Amxx Amxx requested review from ernestognw and cairoeth June 21, 2024 08:39
test/utils/structs/Heap.test.js Outdated Show resolved Hide resolved
scripts/generate/templates/Heap.js Outdated Show resolved Hide resolved
scripts/generate/templates/Heap.js Outdated Show resolved Hide resolved
scripts/generate/templates/Heap.js Outdated Show resolved Hide resolved
scripts/generate/templates/Heap.js Outdated Show resolved Hide resolved
scripts/generate/templates/Heap.js Outdated Show resolved Hide resolved
scripts/generate/templates/Heap.js Outdated Show resolved Hide resolved
scripts/generate/templates/Heap.js Outdated Show resolved Hide resolved
scripts/generate/templates/Heap.js Outdated Show resolved Hide resolved
scripts/generate/templates/Heap.js Show resolved Hide resolved
contracts/utils/structs/Heap.sol Show resolved Hide resolved
scripts/generate/templates/Heap.js Outdated Show resolved Hide resolved
contracts/utils/structs/Heap.sol Outdated Show resolved Hide resolved
contracts/utils/structs/Heap.sol Show resolved Hide resolved
@Amxx Amxx requested review from ernestognw and cairoeth July 19, 2024 06:40
ernestognw
ernestognw previously approved these changes Jul 23, 2024
Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

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

Added some docs, mostly minor things. LGTM

I can reapprove if suggestions are applied

scripts/generate/templates/Heap.js Outdated Show resolved Hide resolved
scripts/generate/templates/Heap.opts.js Outdated Show resolved Hide resolved
scripts/generate/templates/Heap.js Show resolved Hide resolved
scripts/generate/templates/Heap.js Show resolved Hide resolved
scripts/generate/templates/Heap.t.js Show resolved Hide resolved
scripts/generate/templates/Heap.js Outdated Show resolved Hide resolved
@Amxx Amxx requested a review from ernestognw July 23, 2024 07:44
Copy link
Contributor

@cairoeth cairoeth left a comment

Choose a reason for hiding this comment

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

lgtm!

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.

Add priority queue as a data structure to be able to implement max/min heaps
3 participants