2
* Copyright (c) 2010 Daisuke Okanohara
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
8
* 1. Redistributions of source code must retain the above Copyright
9
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above Copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
15
* 3. Neither the name of the authors nor the names of its contributors
16
* may be used to endorse or promote products derived from this
17
* software without specific prior written permission.
20
#ifndef WAT_ARRAY_BIT_ARRAY_HPP_
21
#define WAT_ARRAY_BIT_ARRAY_HPP_
30
NOTFOUND = 0xFFFFFFFFFFFFFFFFLLU
44
BitArray(uint64_t size);
45
uint64_t length() const;
46
uint64_t one_num() const;
48
void Init(uint64_t size);
50
void SetBit(uint64_t bit, uint64_t pos);
52
uint64_t Rank(uint64_t bit, uint64_t pos) const;
53
uint64_t Select(uint64_t bit, uint64_t rank) const;
54
uint64_t Lookup(uint64_t pos) const;
56
static uint64_t PopCount(uint64_t x);
57
static uint64_t PopCountMask(uint64_t x, uint64_t offset);
58
static uint64_t SelectInBlock(uint64_t x, uint64_t rank);
59
static uint64_t GetBitNum(uint64_t one_num, uint64_t num, uint64_t bit);
60
void PrintForDebug(std::ostream& os) const;
62
void Save(std::ostream& os) const;
63
void Load(std::istream& is);
66
uint64_t RankOne(uint64_t pos) const;
67
uint64_t SelectOutBlock(uint64_t bit, uint64_t& rank) const;
70
std::vector<uint64_t> bit_blocks_;
71
std::vector<uint64_t> rank_tables_;
78
#endif // WAT_ARRAY_BIT_ARRAY_HPP_