123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #include "utils/Utility.h"
- int Core::popcount(int i) {
- int count = 0;
- static constexpr int map[16] = {
- 0, // 0000
- 1, // 0001
- 1, // 0010
- 2, // 0011
- 1, // 0100
- 2, // 0101
- 2, // 0110
- 3, // 0111
- 1, // 1000
- 2, // 1001
- 2, // 1010
- 3, // 1011
- 2, // 1100
- 3, // 1101
- 3, // 1110
- 4, // 1111
- };
- for(int k = 0; k < static_cast<int>(sizeof(int) * 8); k += 4) {
- count += map[(i >> k) & 0xF];
- }
- return count;
- }
- void* operator new(size_t bytes) noexcept {
- return malloc(bytes);
- }
- void* operator new[](size_t bytes) noexcept {
- return malloc(bytes);
- }
- void operator delete(void* p) noexcept {
- free(p);
- }
- void operator delete[](void* p) noexcept {
- free(p);
- }
- void operator delete(void* p, size_t bytes) noexcept {
- (void)bytes;
- free(p);
- }
- void operator delete[](void* p, size_t bytes) noexcept {
- (void)bytes;
- free(p);
- }
- void* operator new(size_t bytes, void* p) noexcept {
- (void)bytes;
- return p;
- }
- void* operator new[](size_t bytes, void* p) noexcept {
- (void)bytes;
- return p;
- }
|