forked from z1dev/zkanji
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bits.h
51 lines (40 loc) · 1.44 KB
/
bits.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
/*
** Copyright 2007-2013, 2017-2018 Sólyom Zoltán
** This file is part of zkanji, a free software released under the terms of the
** GNU General Public License version 3. See the file LICENSE for details.
**/
#ifndef BITS_H
#define BITS_H
#include "fastarray.h"
class QDataStream;
class BitArray : public fastarray<char>
{
public:
typedef size_t size_type;
BitArray();
BitArray(const BitArray &src);
BitArray(BitArray &&src);
BitArray& operator=(const BitArray &src);
BitArray& operator=(BitArray &&src);
void load(QDataStream &stream);
// Resizes the bits array to fit at least size bits. Values with indexes
// above the old size will be uninitialized.
void resize(size_type size);
// Changes the size of the bits array to fit at least size bits. All
// values in the array can be considered uninitialized after the call.
void setSize(size_type size);
// Changes the size of the bits array, setting the bits to the value of
// toggle.
void setSize(size_type size, bool toggle);
// Returns the number of bits that the bits array can hold.
size_type size() const;
// Returns whether the bit at index is toggled (has a value of 1).
bool toggled(size_type index) const;
// Changes the bit at index to be toggled or not.
void set(size_type index, bool toggle);
private:
size_type bitsize;
typedef fastarray<char> base;
using base::operator[];
};
#endif // BITS_H