File: boolFlagArray.h

package info (click to toggle)
perm 0.4.0-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 976 kB
  • sloc: cpp: 13,499; makefile: 98; sh: 12
file content (33 lines) | stat: -rw-r--r-- 911 bytes parent folder | download | duplicates (5)
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
#pragma once
#include <iostream>
#include <deque>
#include <string.h>
using namespace std;

/**
 * This class is design to use a char to store 8 bool flags
 * as an alternative of vector<bool>. It is easy to dump and
 * read the content of this flag array by fwrite and fread.
 */
class CboolFlagArray
{
public:
    CboolFlagArray(void);
    CboolFlagArray(unsigned int size);
    ~CboolFlagArray(void);
    unsigned char* bflag;
    //The size is # of bits so the real size in bytes is size/8 + 1
    unsigned int size;
    // return true if the flag is set
    bool b(unsigned int index) const;
    // return true if there is a flag set within the widows
    bool b(unsigned int index, unsigned int windowLength) const;
    void setflag(unsigned int index, bool flag);
    unsigned int initialization(unsigned int size);
};

inline unsigned int size2sizeInByte(unsigned int size)
{
    return(size/8 + 1);
}