OR-Tools
8.1
bitmap.cc
Go to the documentation of this file.
1
// Copyright 2010-2018 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 <algorithm>
17
18
#include "
ortools/base/basictypes.h
"
19
20
namespace
operations_research
{
21
22
void
Bitmap::Resize
(
uint32
size,
bool
fill) {
23
const
uint32
new_array_size =
internal::BitLength64
(size);
24
const
uint32
old_max_size = max_size_;
25
if
(new_array_size <= array_size_) {
26
max_size_ = size;
27
}
else
{
28
const
uint32
old_array_size = array_size_;
29
array_size_ = new_array_size;
30
max_size_ = size;
31
uint64
* new_map =
new
uint64
[array_size_];
32
memcpy(new_map, map_, old_array_size *
sizeof
(*map_));
33
delete
[] map_;
34
map_ = new_map;
35
}
36
// TODO(user) : optimize next loop.
37
for
(
uint32
index
= old_max_size;
index
< size; ++
index
) {
38
Set
(
index
, fill);
39
}
40
}
41
}
// namespace operations_research
operations_research::internal::BitLength64
uint64 BitLength64(uint64 size)
Definition:
bitmap.h:26
bitmap.h
operations_research
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
Definition:
dense_doubly_linked_list.h:21
index
int index
Definition:
pack.cc:508
operations_research::Bitmap::Set
void Set(uint32 index, bool value)
Definition:
bitmap.h:62
uint32
unsigned int uint32
Definition:
integral_types.h:38
basictypes.h
uint64
uint64_t uint64
Definition:
integral_types.h:39
operations_research::Bitmap::Resize
void Resize(uint32 size, bool fill=false)
Definition:
bitmap.cc:22
ortools
base
bitmap.cc
Generated by
1.8.20