-
Notifications
You must be signed in to change notification settings - Fork 12k
Add Array.uniquifySorted to the Arrays library #5520
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
Open
gonzaotc opened this issue
Feb 21, 2025
· 0 comments
· May be fixed by sivaratrisrinivas/openzeppelin-contracts#1, #5534 or sivaratrisrinivas/openzeppelin-contracts#3
Open
Add Array.uniquifySorted to the Arrays library #5520
gonzaotc opened this issue
Feb 21, 2025
· 0 comments
· May be fixed by sivaratrisrinivas/openzeppelin-contracts#1, #5534 or sivaratrisrinivas/openzeppelin-contracts#3
Comments
8 tasks
sivaratrisrinivas
added a commit
to sivaratrisrinivas/openzeppelin-contracts
that referenced
this issue
Feb 27, 2025
This adds a uniquifySorted function to remove duplicates from sorted arrays. The function has O(n) time complexity and works with uint256, address, and bytes32 array types. This is particularly useful when mappings cannot be utilized, and provides an easy way to combine Array.sort() + Array.uniquifySorted(). Fixes OpenZeppelin#5520 Co-Authored-By: Srinivas Sivaratri <[email protected]>
This was referenced Feb 27, 2025
sivaratrisrinivas
added a commit
to sivaratrisrinivas/openzeppelin-contracts
that referenced
this issue
Feb 27, 2025
This adds a uniquifySorted function that removes duplicates from sorted arrays. Implements functionality requested in issue OpenZeppelin#5520. Co-Authored-By: Srinivas Sivaratri <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🧐 Motivation
With the recent addition of sorting via quickSort to the library, results very convenient for consumers to also have an
Array.uniquifySorted
available for uniquifying sorted arrays.📝 Details
In some cases, when we cannot utilize mappings, we utilize the Array library to eliminate duplicates on short-sized arrays, which could be easily done by executing Array.sort() + Array.uniquifySorted().
The text was updated successfully, but these errors were encountered: