Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
bitmap.cc
Go to the documentation of this file.
1// Copyright 2010-2024 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#include "ortools/base/bitmap.h"
15
16#include <cstdint>
17
18namespace operations_research {
19
20void Bitmap::Resize(uint32_t size, bool fill) {
21 const uint32_t new_array_size = internal::BitLength64(size);
22 const uint32_t old_max_size = max_size_;
23 if (new_array_size <= array_size_) {
24 max_size_ = size;
25 } else {
26 const uint32_t old_array_size = array_size_;
27 array_size_ = new_array_size;
28 max_size_ = size;
29 uint64_t* new_map = new uint64_t[array_size_];
30 memcpy(new_map, map_, old_array_size * sizeof(*map_));
31 delete[] map_;
32 map_ = new_map;
33 }
34 // TODO(user) : optimize next loop.
35 for (uint32_t index = old_max_size; index < size; ++index) {
36 Set(index, fill);
37 }
38}
39} // namespace operations_research
IntegerValue size
void Resize(uint32_t size, bool fill=false)
Definition bitmap.cc:20
void Set(uint32_t index, bool value)
Definition bitmap.h:62
int index
uint64_t BitLength64(uint64_t size)
Definition bitmap.h:26
In SWIG mode, we don't want anything besides these top-level includes.