My Project
bit.h
Go to the documentation of this file.
1
11#ifndef EDAX_BIT_H
12#define EDAX_BIT_H
13
14#include <stdio.h>
15
16#ifdef DLL_BUILD
17#define DLL_API __declspec(dllexport)
18#else
19#define DLL_API
20#endif
21
22struct Random;
23
24/* declaration */
25DLL_API int bit_count(unsigned long long);
26int bit_weighted_count(const unsigned long long);
27DLL_API int first_bit(unsigned long long);
28int next_bit(unsigned long long*);
29DLL_API int last_bit(unsigned long long);
30void bitboard_write(const unsigned long long, FILE*);
31unsigned long long transpose(unsigned long long);
32unsigned long long vertical_mirror(unsigned long long);
33unsigned long long horizontal_mirror(unsigned long long);
34unsigned int bswap_int(unsigned int);
35unsigned short bswap_short(unsigned short);
36int get_rand_bit(unsigned long long, struct Random*);
37
39#define foreach_bit(i, b) for (i = first_bit(b); b; i = next_bit(&b))
40
41extern const unsigned long long X_TO_BIT[];
43#define x_to_bit(x) X_TO_BIT[x]
44
45//#define x_to_bit(x) (1ULL << (x)) // 1% slower on Sandy Bridge
46
47#endif
48
DLL_API int last_bit(unsigned long long)
Search the last bit set (same as log2()).
Definition: bit.c:264
unsigned int bswap_int(unsigned int)
Mirror the unsigned int (little <-> big endian).
Definition: bit.c:401
unsigned long long horizontal_mirror(unsigned long long)
Mirror the unsigned long long (exchange the line 1 - 8, 2 - 7, 3 - 6 & 4 - 5).
Definition: bit.c:377
DLL_API int bit_count(unsigned long long)
Count the number of bits set to one in an unsigned long long.
Definition: bit.c:72
int get_rand_bit(unsigned long long, struct Random *)
Get a random set bit index.
Definition: bit.c:415
#define DLL_API
Definition: bit.h:19
int bit_weighted_count(const unsigned long long)
count the number of discs, counting the corners twice.
Definition: bit.c:143
unsigned long long vertical_mirror(unsigned long long)
Mirror the unsigned long long (exchange the lines A - H, B - G, C - F & D - E.).
Definition: bit.c:364
int next_bit(unsigned long long *)
Search the next bit set.
Definition: bit.c:248
unsigned long long transpose(unsigned long long)
Transpose the unsigned long long (symetry % A1-H8 diagonal).
Definition: bit.c:345
DLL_API int first_bit(unsigned long long)
Search the first bit set.
Definition: bit.c:173
const unsigned long long X_TO_BIT[]
Definition: bit.c:18
void bitboard_write(const unsigned long long, FILE *)
Print an unsigned long long as a board.
Definition: bit.c:435
unsigned short bswap_short(unsigned short)
Swap bytes of a short (little <-> big endian).
Definition: bit.c:391
Definition: util.h:87