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. */
| 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. */ |
| 164 | static 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 | /*-******************************************************** |
no test coverage detected