Skip to content

Allow custom collections for multi cartesian product items #345

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aschampion
Copy link

Allow MultiProduct to yield collections other than Vec. The main
value is that callers can specify non-allocating types like SmallVec, meaning that
iteration over a multi-cartesian product can be non-allocating. Creating
the product itself is still an allocation, however.

To not be a breaking change, the multi_cartesian_product method still
returns a product iterating over Vec (since method generics can not
specify defaults), and a new generic method
multi_cartesian_product_with is added (test with VecDeque included).

I'm open to suggestions for a better name for the new method.

As expected, there's no performance regression from master:

test multi_cartesian_product_fold             ... bench:     341,218 ns/iter (+/- 19,384)
test multi_cartesian_product_iterator         ... bench:     346,154 ns/iter (+/- 91,213)

This PR:

test multi_cartesian_product_fold             ... bench:     343,430 ns/iter (+/- 56,536)
test multi_cartesian_product_iterator         ... bench:     341,383 ns/iter (+/- 10,901)

Allow `MultiProduct` to yield collections other than `Vec`. The main
value is that callers can specify non-allocating types, meaning that
iteration over a multi-cartesian product can be non-allocating. Creating
the product itself is still an allocation, however.

To not be a breaking change, the `multi_cartesian_product` method still
returns a product iterating over `Vec` (since method generics can not
specify defaults), and a new generic method
`multi_cartesian_product_with` is added.
@aschampion aschampion force-pushed the features/custom-mcp-collections branch from 29a7bbd to db54f58 Compare May 23, 2019 12:43
@jswrenn jswrenn self-assigned this Jul 18, 2019
@Philippe-Cholet Philippe-Cholet added the generic-container Generic vector/hasher/map label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants