-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Changes from 29 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
4fec530
implement binary heap
Amxx 8fa2eeb
codespell & lib naming
Amxx 792fcba
tests
Amxx 0c86005
fix fuzzing tests
Amxx 248baf6
codespell
Amxx 53db2ab
update
Amxx 945e0f4
procedural generation
Amxx df82b15
testing
Amxx 8b965fc
overflow handling
Amxx e952cf6
add replace and changeset
Amxx f5fa274
rename top -> peek
Amxx 1f0fef0
internal renaming
Amxx d0972a3
codespell
Amxx 8e3dda6
regenerate
Amxx 38e1813
auto regenerate
Amxx 02f224d
Update .githooks/pre-push
Amxx 7e88481
up
Amxx a46cc63
Merge branch 'master' into struct/heap
Amxx b2fda31
up
Amxx 516f1ca
tests
Amxx cf1278e
Update test/utils/structs/Heap.test.js
Amxx 5f15d1c
Update test/utils/structs/Heap.test.js
Amxx 32e9b49
Apply suggestions from code review
Amxx c083d79
regenrate
Amxx 0e6ada0
Merge branch 'master' into struct/heap
Amxx 7c98102
update inline comments
Amxx a1767d4
update
Amxx 1c1e84b
Address comment for the PR
Amxx 0e7fe7a
rewrite Arrays.sol to use uint256[] as the default, and use Comparato…
Amxx d495859
Update scripts/generate/templates/Heap.js
Amxx fe8e902
regenerate
Amxx 3abeb84
Add docs
ernestognw 8801d98
Update scripts/generate/templates/Heap.js
Amxx f78df0c
Apply suggestions from code review
Amxx bb37dfb
fix generation + change key type
Amxx 1fb4b81
more invariant check
Amxx d3308c4
Update scripts/generate/templates/Heap.js
ernestognw 5b07512
Generate
ernestognw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'openzeppelin-solidity': minor | ||
--- | ||
|
||
`Comparator`: A library of comparator functions, useful for customizing the behavior of the Heap structure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'openzeppelin-solidity': minor | ||
--- | ||
|
||
`Heap`: A data structure that implements a heap-based priority queue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
set -euo pipefail | ||
|
||
if [ "${CI:-"false"}" != "true" ]; then | ||
npm run test:generation | ||
npm run lint | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea of having comparators so that the heap is customizable. However, this library feels odd. Is this something we see value in providing on its own file? I'd rather keep it undocumented and inside Heap.sol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
library Comparators { | ||
function lt(uint256 a, uint256 b) internal pure returns (bool) { | ||
return a < b; | ||
} | ||
|
||
function gt(uint256 a, uint256 b) internal pure returns (bool) { | ||
return a > b; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not adding Comparators here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was overlooked, and since there are currently no tests for the
Comparators
library, it missing did not triger any issue.Lets start by discussing weither we want the comparator library or not ... then we can add tests and solve that