123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #include "utils/Utility.h"
- int Core::popcount(int i) {
- int count = 0;
- static constexpr int map[16] = {
- 0,
- 1,
- 1,
- 2,
- 1,
- 2,
- 2,
- 3,
- 1,
- 2,
- 2,
- 3,
- 2,
- 3,
- 3,
- 4,
- };
- 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;
- }
|