Skip to content

feat(utils): add values(start, end) slice accessor to DoubleEndedQueue - #167

Merged
luiz-lvj merged 1 commit into
masterfrom
feat/deque-values-slice
Sep 17, 2026
Merged

luiz-lvj merged 1 commit into
masterfrom
feat/deque-values-slice

Conversation

@luiz-lvj

Copy link
Copy Markdown
Collaborator

Summary

Ports OpenZeppelin/openzeppelin-contracts#6522 from openzeppelin-contracts 5.7.0.

Adds values(deque, start, end), returning the [start, end) slice of the queue as an array. Out-of-bound start/end are clamped to the queue length, mirroring the paginated values accessor in EnumerableSet.

@luiz-lvj
luiz-lvj requested a review from pepebndc September 15, 2026 17:53

@pepebndc pepebndc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@pepebndc

Copy link
Copy Markdown
Collaborator

Add tests for values(start, end) in test/utils/structs/DoubleEndedQueue.test.js: empty queue, full range, end past the length, and start > end. The NatSpec can also state that start > end returns an empty array.

…ueue`

## Summary

Ports [OpenZeppelin/openzeppelin-contracts#6522](OpenZeppelin/openzeppelin-contracts#6522) from openzeppelin-contracts 5.7.0.

Adds `values(deque, start, end)`, returning the `[start, end)` slice of the queue as an array. Out-of-bound `start`/`end` are clamped to the queue length, mirroring the paginated `values` accessor in `EnumerableSet`.
@luiz-lvj
luiz-lvj force-pushed the feat/deque-values-slice branch from 946d4f1 to de2ea2f Compare September 16, 2026 14:19
@luiz-lvj

Copy link
Copy Markdown
Collaborator Author

Done. The values(start, end) tests are in test/utils/structs/DoubleEndedQueue.test.js: empty queue (values returns empty array), full range (returns the full content for [0, length)), pagination across all begin/end combinations, end past the length (clamps end to length), and start > end (clamps start to end), plus a wraparound case. They landed in the PR itself, after this comment. On the NatSpec suggestion: upstream #6522 doesn't document the start > end behavior in the values docstring, so I left it matching upstream to keep the port exact.

@luiz-lvj
luiz-lvj merged commit 64629bb into master Sep 17, 2026
18 checks passed
@luiz-lvj
luiz-lvj deleted the feat/deque-values-slice branch September 17, 2026 18:14
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.

2 participants