ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
FastGeneration.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------- File FastGeneration.h --------------------------*/
3/*--------------------------------------------------------------------------*/
69/*--------------------------------------------------------------------------*/
70/*----------------------------- DEFINITIONS --------------------------------*/
71/*--------------------------------------------------------------------------*/
72
73#ifndef __ADS_FastGeneration
74 #define __ADS_FastGeneration
75/* self-identification: #endif constant */
76
77/*--------------------------------------------------------------------------*/
78/*------------------------------ INCLUDES ----------------------------------*/
79/*--------------------------------------------------------------------------*/
80
81#include "ADS/Contract.h"
84
85#include <algorithm>
86#include <bit>
87#include <cstdint>
88#include <type_traits>
89#include <utility>
90#include <vector>
91
92/*--------------------------------------------------------------------------*/
93/*--------------------------- NAMESPACE ------------------------------------*/
94/*--------------------------------------------------------------------------*/
95
96namespace ADS
97{
98
124template< class T , class F >
125long forEachPermutation( std::vector< T > & a , F && visit );
126
157template< class T , class F >
158long forEachPermutationLex( std::vector< T > & a , F && visit );
159
182template< class F >
183long forEachCombination( int n , int t , F && visit );
184
199[[nodiscard]] constexpr Word nextCombination( Word x );
200
223template< class F >
224long forEachCombinationMask( int n , int t , F && visit );
225
226/*--------------------------------------------------------------------------*/
227
228} // end( namespace ADS )
229
230/*--------------------------------------------------------------------------*/
231/*-------------------------- IMPLEMENTATION --------------------------------*/
232/*--------------------------------------------------------------------------*/
233
234#include "ADS/combinatorial/impl/FastGeneration.tpp"
235
236/*--------------------------------------------------------------------------*/
237
238#endif /* FastGeneration.h included */
239
240/*--------------------------------------------------------------------------*/
241/*----------------------- End File FastGeneration.h ------------------------*/
242/*--------------------------------------------------------------------------*/
The broadword tricks of Knuth (section 7.1.3 of The Art of Computer Programming), beyond the book: op...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The generation of the basic combinatorial objects of Knuth (section 7.2.1 of The Art of Computer Prog...
long forEachPermutation(std::vector< T > &a, F &&visit)
the arrangements of by Heap's method, visit( a ) on each
long forEachCombinationMask(int n, int t, F &&visit)
the words of 1 bits below in increasing order, visit( x ) on each
long forEachPermutationLex(std::vector< T > &a, F &&visit)
the distinct permutations of the multiset in lexicographic order from sorted, visit( a ) on each; ...
long forEachCombination(int n, int t, F &&visit)
the increasing -tuples of in lexicographic order, visit( c ) on each, a const std::vector< int > of...
constexpr Word nextCombination(Word x)
the next larger word with as many 1 bits as
Definition ADT.h:96
std::uint64_t Word
a word of 64 bits
Definition Bitwise.h:73