typedb / typedb-common

TypeDB Common Libraries and Scripts
GNU Affero General Public License v3.0
7 stars 14 forks source link

Lazily generate permutations #132

Closed flyingsilverfin closed 1 year ago

flyingsilverfin commented 2 years ago

Problem to Solve

The Collections.permutations(List<T>) method is currently eager: it generates all permutations of the list and returns a list of these. However, it would be better to lazily generate the permutations.

Proposed Solution

We should return an Iterator<List<T>> which returns a different input permutation, generating the permutations on the fly, ideally without consuming O(n!) memory.

flyingsilverfin commented 1 year ago

Solved by #134