Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

0leksandr/combinator

Repository files navigation

Combinator

Service for generating collection of subsets from passed collection(s) (std::array or std::vector).

Example:

Combinator(std::vector<int>({1, 2, 3}), 2) ≈ {
 {1, 2},
 {1, 3},
 {2, 3},
};
Permutator(std::vector<int>({1, 2, 3}), 2) ≈ {
 {1, 2},
 {1, 3},
 {2, 1},
 {2, 3},
 {3, 1},
 {3, 2},
};
MultiPermutator(std::vector<int>({1, 2, 3}), 2) ≈ {
 {1, 1},
 {2, 1},
 {3, 1},
 {1, 2},
 {2, 2},
 {3, 2},
 {1, 3},
 {2, 3},
 {3, 3},
};
Cartesian(std::vector<std::vector<int>>({std::vector<int>{1, 2}, {3, 4}})) ≈ {
 {1, 3}, 
 {2, 3},
 {1, 4},
 {2, 4},
};

Works as forward-iterator and random-access-iterator, thus allows to generate arbitrary big sequenses, requiring minimum amount of memory.

Accepts collections of any objects (integers are shows as example).

Returns sets of std::array or std::vector (required type should be declared as template argument, or will be deducted from input argument).

About

Generator of combinations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /