-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiBitmap.cpp
More file actions
54 lines (50 loc) · 935 Bytes
/
multiBitmap.cpp
File metadata and controls
54 lines (50 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "multiBitmap.h"
#include <cmath>
#include <memory>
#define NULL 0
using namespace std;
CMultiBitMap :: CMultiBitMap(const size_t size)
{
bits = NULL ;
bitSize = size ; //bit位的大小
if (size)
{
int tempSize = size >> SHIFT ;
if (size & MASK)
tempSize ++ ;
bits = new int[tempSize] ; //申请空间
memset(bits, 0, sizeof(int)*tempSize) ; //全部清0
}
}
CMultiBitMap :: ~CMultiBitMap()
{
if (bits != NULL)
{
delete[] bits ;
bits = NULL ;
}
}
void CMultiBitMap :: resize(size_t newSize)
{
if (newSize != bitSize)
{
bitSize = newSize ;
if (bits != NULL)
{
delete[] bits ;
bits = NULL ;
}
int tempSize = bitSize >> SHIFT ;
if (bitSize & MASK)
tempSize ++ ;
bits = new int[tempSize] ;
memset(bits, 0, sizeof(int)*tempSize) ; //全部清0
}
else
{
int tempSize = bitSize >> SHIFT ;
if (bitSize & MASK)
tempSize ++ ;
memset(bits, 0, sizeof(int)*tempSize) ; //全部清0
}
}