|
@ -1,4 +1,6 @@ |
|
|
#pragma once |
|
|
#pragma once |
|
|
|
|
|
#include<cstddef> |
|
|
|
|
|
#include "storm/utility/macros.h" |
|
|
|
|
|
|
|
|
inline size_t smallestIntWithNBitsSet(size_t n) { |
|
|
inline size_t smallestIntWithNBitsSet(size_t n) { |
|
|
static_assert(sizeof(size_t) == 8, "size_t has wrong size."); |
|
|
static_assert(sizeof(size_t) == 8, "size_t has wrong size."); |
|
@ -11,5 +13,5 @@ inline size_t nextBitPermutation(size_t v) { |
|
|
if (v==0) return static_cast<size_t>(0); |
|
|
if (v==0) return static_cast<size_t>(0); |
|
|
// From https://graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation |
|
|
// From https://graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation |
|
|
size_t t = (v | (v - 1)) + 1; |
|
|
size_t t = (v | (v - 1)) + 1; |
|
|
return t | ((((t & -t) / (v & -v)) >> 1) - 1); |
|
|
|
|
|
|
|
|
return t | ((((t & -t) / (v & -v)) >> 1) - 1); |
|
|
} |
|
|
} |