MCPcopy Index your code
hub / github.com/RT-Thread/rt-thread / init_random_keys

Function init_random_keys

examples/test/avl.c:249–266  ·  view source on GitHub ↗

generate keys

Source from the content-addressed store, hash-verified

247
248// generate keys
249static inline void init_random_keys(int *keys, int count, int seed)
250{
251 int save_seed = time(NULL);
252 int *array = (int*)malloc(sizeof(int) * count);
253 int length = count, i;
254 xseed = seed;
255 for (i = 0; i < count; i++) {
256 array[i] = i;
257 }
258 for (i = 0; i < length; i++) {
259 int pos = xrand() % count;
260 int key = array[pos];
261 keys[i] = key;
262 array[pos] = array[--count];
263 }
264 free(array);
265 xseed = save_seed;
266}
267
268// A utility function to swap to integers
269static inline void swap (int *a, int *b)

Callers 1

init_testFunction · 0.85

Calls 4

timeFunction · 0.85
xrandFunction · 0.85
mallocFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected