00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "base/bitmap.h"
00015
00016 #include <algorithm>
00017
00018 #include "base/basictypes.h"
00019
00020 namespace operations_research {
00021
00022 void Bitmap::Resize(uint32 size, bool fill) {
00023 const uint32 new_array_size = BitLength64(size);
00024 const uint32 old_max_size = max_size_;
00025 if (new_array_size <= array_size_) {
00026 max_size_ = size;
00027 } else {
00028 const uint32 old_array_size = array_size_;
00029 array_size_ = new_array_size;
00030 max_size_ = size;
00031 uint64* new_map = new uint64[array_size_];
00032 memcpy(new_map, map_, old_array_size * sizeof(*map_));
00033 delete [] map_;
00034 map_ = new_map;
00035 }
00036
00037 for (uint32 index = old_max_size; index < size; ++index) {
00038 Set(index, fill);
00039 }
00040 }
00041 }