-
Notifications
You must be signed in to change notification settings - Fork 0
/
BitList.h
65 lines (57 loc) · 1.03 KB
/
BitList.h
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
55
56
57
58
59
60
61
62
63
64
65
//
// Created by 郑元庆 on 15/7/9.
// Copyright (c) 2015 郑元庆. All rights reserved.
//
#ifndef __BitList_H_
#define __BitList_H_
#include <iostream>
#include <vector>
/**
* 位链表
*/
class BitList
{
public:
/**
* bit size
*/
BitList(const unsigned long long size);
~BitList();
public:
/**
* 重置元素
*
* @param val 0(false) or 1(true)
*/
void reset(const bool val);
/**
* bit大小
*
* @return bits
*/
long long size();
/**
* []重载
*
* @param index 位下标
*
* @return 0(false) or 1(true)
*/
bool operator[](const unsigned long long index);
/**
* 设置元素
*
* @param size 位下标
* @param val 0(false) or 1(true)
*/
void set_value(const unsigned long long index, const bool val);
/**
* 清空内存
*/
void clear();
private:
std::vector<unsigned char*> _data;
unsigned long long _size;//bit大小
size_t _block_size;//链表块大小
};
#endif //__BitList_H_