xref: /haiku/src/tests/add-ons/kernel/file_systems/bfs/array/smallArray.cpp (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
1 #include "Utility.h"
2 
3 #include <List.h>
4 #include <stdlib.h>
5 #include <stdio.h>
6 
7 
8 int32 gIterations = 1000000;
9 int32 gNumber = 8;
10 
11 
12 int
13 main(int argc,char **argv)
14 {
15 	char buffer[1024];
16 	sorted_array *array = (sorted_array *)buffer;
17 	array->count = 0;
18 
19 	srand(42);
20 
21 	for (int32 i = 0;i < gIterations;i++) {
22 		// add entries to the array
23 
24 		for (int32 num = 0;num < gNumber;num++)
25 			array->Insert(rand());
26 
27 		for (int32 num = 0;num < gNumber;num++) {
28 			int32 index = int32(1.0 * rand() * array->count / RAND_MAX);
29 			array->Remove(array->values[index]);
30 		}
31 	}
32 	return 0;
33 }
34