1 #ifndef __bin_utils_h__
2 #define __bin_utils_h__
9 * Generating a list of peak bins for corresponding length
11 inline int gen_peaks(uint64_t length, bin_t * peaks) {
17 peaks[pp++] = bin_t(((2 * length - 1) << layer) - 1);
22 for(int i = 0; i < (pp >> 1); ++i) {
23 bin_t memo = peaks[pp - 1 - i];
24 peaks[pp - 1 - i] = peaks[i];
28 peaks[pp] = bin_t::NONE;
34 * Checking for that the bin value is fit to uint32_t
36 inline bool bin_isUInt32(const bin_t & bin) {
42 const uint64_t v = bin.toUInt();
44 return static_cast<uint32_t>(v) == v && v != 0xffffffff && v != 0x7fffffff;
49 * Convert the bin value to uint32_t
51 inline uint32_t bin_toUInt32(const bin_t & bin) {
56 return static_cast<uint32_t>(bin.toUInt());
61 * Convert the bin value to uint64_t
63 inline uint64_t bin_toUInt64(const bin_t & bin) {
69 * Restore the bin from an uint32_t value
71 inline bin_t bin_fromUInt32(uint32_t v) {
76 return bin_t(static_cast<uint64_t>(v));
81 * Restore the bin from an uint64_t value
83 inline bin_t bin_fromUInt64(uint64_t v) {
84 return bin_t(static_cast<uint64_t>(v));
88 #endif /*_bin_utils_h__*/