-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Add Binary heap structure #5084
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
Changes from 19 commits
4fec530
8fa2eeb
792fcba
0c86005
248baf6
53db2ab
945e0f4
df82b15
8b965fc
e952cf6
f5fa274
1f0fef0
d0972a3
8e3dda6
38e1813
02f224d
7e88481
a46cc63
b2fda31
516f1ca
cf1278e
5f15d1c
32e9b49
c083d79
0e6ada0
7c98102
a1767d4
1c1e84b
0e7fe7a
d495859
fe8e902
3abeb84
8801d98
f78df0c
bb37dfb
1fb4b81
d3308c4
5b07512
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. |
| 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. | ||
| 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 | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,7 @@ import {ERC165} from "../utils/introspection/ERC165.sol"; | |||||||
| import {ERC165Checker} from "../utils/introspection/ERC165Checker.sol"; | ||||||||
| import {ERC1967Utils} from "../proxy/ERC1967/ERC1967Utils.sol"; | ||||||||
| import {ERC721Holder} from "../token/ERC721/utils/ERC721Holder.sol"; | ||||||||
| import {Heap} from "../utils/structs/Heap.sol"; | ||||||||
|
Member
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. Why not adding Comparators here?
Suggested change
Collaborator
Author
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. It was overlooked, and since there are currently no tests for the Lets start by discussing weither we want the comparator library or not ... then we can add tests and solve that |
||||||||
| import {Math} from "../utils/math/Math.sol"; | ||||||||
| import {MerkleProof} from "../utils/cryptography/MerkleProof.sol"; | ||||||||
| import {MessageHashUtils} from "../utils/cryptography/MessageHashUtils.sol"; | ||||||||
|
|
||||||||
|
Member
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 |
| 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; | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.