-
Notifications
You must be signed in to change notification settings - Fork 0
/
BooleanArray.h
67 lines (63 loc) · 1.87 KB
/
BooleanArray.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
66
67
/**
* @file BooleanArray.h
* @brief Header file for BooleanArray
* @author Yousef Said
*/
#ifndef _BITSBOOLEANARRAY_H_
#define _BITSBOOLEANARRAY_H_
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include <stdexcept>
/**
* @brief A global variable represents the size of datatype used in implementation
*/
extern const size_t CHUNK_SIZE;
/**
* @brief An array of booleans class
* @details This class is intended to be used for storing array of boolean with minimum loss
*/
class BooleanArray
{
private:
/**
* @brief A private member variable which is the pointer used to point to dynamic memory allocated for the array
*/
uint8_t *arr;
/**
* @brief A private member variable stores the max number of booleans stored in array
*/
size_t MAX_SIZE;
/**
* @brief A private member variable stores the actual size in bytes of the array
*/
size_t OBJ_SIZE;
public:
/**
* @brief Constructor for BooleanArray
* @param MAX_SIZE intializer for internal array size and MAX_SIZE
*/
BooleanArray(size_t MAX_SIZE);
/**
* @brief Destructor for BooleanArray
* @details This destructor is used to deallocte internal array
*/
~BooleanArray();
/**
* @brief Overloaded [] operator for BooleanArray
* @param index index of the boolean item to get
* @return the boolean value in the requested index
*/
bool operator[](size_t index);
/**
* @brief Public method to set value at an index in array
* @param index index specifiy the (index) in array
* @param val (val) is the new value we want to set it
*/
void set(size_t index, bool val);
/**
* @brief Public method to get the total space occupied by the boolean array in memory
*/
size_t getobjectsize();
};
#endif // _BITSBOOLEANARRAY_H_