118 BitMap(bm_word_t* map, idx_t size_in_bits) :_map(map), _size(size_in_bits) {}
119
120 // Constructs an empty bitmap of the given size (that is, this clears the
121 // new bitmap). Allocates the map array in resource area if
122 // "in_resource_area" is true, else in the C heap.
123 BitMap(idx_t size_in_bits, bool in_resource_area = true);
124
125 // Set the map and size.
126 void set_map(bm_word_t* map) { _map = map; }
127 void set_size(idx_t size_in_bits) { _size = size_in_bits; }
128
129 // Allocates necessary data structure, either in the resource area
130 // or in the C heap, as indicated by "in_resource_area."
131 // Preserves state currently in bit map by copying data.
132 // Zeros any newly-addressable bits.
133 // If "in_resource_area" is false, frees the current map.
134 // (Note that this assumes that all calls to "resize" on the same BitMap
135 // use the same value for "in_resource_area".)
136 void resize(idx_t size_in_bits, bool in_resource_area = true);
137
138 // Accessing
139 idx_t size() const { return _size; }
140 idx_t size_in_words() const {
141 return word_index(size() + BitsPerWord - 1);
142 }
143
144 bool at(idx_t index) const {
145 verify_index(index);
146 return (*word_addr(index) & bit_mask(index)) != 0;
147 }
148
149 // Align bit index up or down to the next bitmap word boundary, or check
150 // alignment.
151 static idx_t word_align_up(idx_t bit) {
152 return align_size_up(bit, BitsPerWord);
153 }
154 static idx_t word_align_down(idx_t bit) {
155 return align_size_down(bit, BitsPerWord);
156 }
157 static bool is_word_aligned(idx_t bit) {
158 return word_align_up(bit) == bit;
159 }
160
161 // Set or clear the specified bit.
|
118 BitMap(bm_word_t* map, idx_t size_in_bits) :_map(map), _size(size_in_bits) {}
119
120 // Constructs an empty bitmap of the given size (that is, this clears the
121 // new bitmap). Allocates the map array in resource area if
122 // "in_resource_area" is true, else in the C heap.
123 BitMap(idx_t size_in_bits, bool in_resource_area = true);
124
125 // Set the map and size.
126 void set_map(bm_word_t* map) { _map = map; }
127 void set_size(idx_t size_in_bits) { _size = size_in_bits; }
128
129 // Allocates necessary data structure, either in the resource area
130 // or in the C heap, as indicated by "in_resource_area."
131 // Preserves state currently in bit map by copying data.
132 // Zeros any newly-addressable bits.
133 // If "in_resource_area" is false, frees the current map.
134 // (Note that this assumes that all calls to "resize" on the same BitMap
135 // use the same value for "in_resource_area".)
136 void resize(idx_t size_in_bits, bool in_resource_area = true);
137
138 // Pretouch the entire range of memory this BitMap covers.
139 void pretouch();
140
141 // Accessing
142 idx_t size() const { return _size; }
143 idx_t size_in_words() const {
144 return word_index(size() + BitsPerWord - 1);
145 }
146
147 static idx_t size_in_words(size_t size_in_bits) {
148 return word_index(size_in_bits + BitsPerWord - 1);
149 }
150
151 bool at(idx_t index) const {
152 verify_index(index);
153 return (*word_addr(index) & bit_mask(index)) != 0;
154 }
155
156 // Align bit index up or down to the next bitmap word boundary, or check
157 // alignment.
158 static idx_t word_align_up(idx_t bit) {
159 return align_size_up(bit, BitsPerWord);
160 }
161 static idx_t word_align_down(idx_t bit) {
162 return align_size_down(bit, BitsPerWord);
163 }
164 static bool is_word_aligned(idx_t bit) {
165 return word_align_up(bit) == bit;
166 }
167
168 // Set or clear the specified bit.
|