Remove old shuffle header

This commit is contained in:
Justine Tunney 2024-12-30 03:03:32 -08:00
parent c7e3d9f7ff
commit a51ccc8fb1
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
5 changed files with 64 additions and 32 deletions

View file

@ -1,21 +0,0 @@
#ifndef COSMOPOLITAN_LIBC_RAND_SHUFFLE_H_
#define COSMOPOLITAN_LIBC_RAND_SHUFFLE_H_
#include "libc/intrin/xchg.h"
/**
* Fisher-Yates shuffle.
*
* @param R is a function like rand() 0
* @param A is a typed array
* @param n is the number of items in A
* @see ARRAYLEN()
*/
#define shuffle(R, A, n) \
do { \
autotype(A) Array = (A); \
for (size_t i = (n) - 1; i >= 1; --i) { \
xchg(&Array[i], &Array[R() % (i + 1)]); \
} \
} while (0)
#endif /* COSMOPOLITAN_LIBC_RAND_SHUFFLE_H_ */