MCPcopy Create free account
hub / github.com/F-Stack/f-stack / DiB_shuffle

Function DiB_shuffle

freebsd/contrib/zstd/programs/dibio.c:164–174  ·  view source on GitHub ↗

DiB_shuffle() : * shuffle a table of file names in a semi-random way * It improves dictionary quality by reducing "locality" impact, so if sample set is very large, * it will load random elements from it, instead of just the first ones. */

Source from the content-addressed store, hash-verified

162 * It improves dictionary quality by reducing "locality" impact, so if sample set is very large,
163 * it will load random elements from it, instead of just the first ones. */
164static void DiB_shuffle(const char** fileNamesTable, unsigned nbFiles) {
165 U32 seed = 0xFD2FB528;
166 unsigned i;
167 assert(nbFiles >= 1);
168 for (i = nbFiles - 1; i > 0; --i) {
169 unsigned const j = DiB_rand(&seed) % (i + 1);
170 const char* const tmp = fileNamesTable[j];
171 fileNamesTable[j] = fileNamesTable[i];
172 fileNamesTable[i] = tmp;
173 }
174}
175
176
177/*-********************************************************

Callers 1

DiB_trainFromFilesFunction · 0.85

Calls 1

DiB_randFunction · 0.85

Tested by

no test coverage detected