-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBt_StaticArray.hpp
81 lines (60 loc) · 1.64 KB
/
Bt_StaticArray.hpp
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//*************************************************************************************************
//
// BITTAILOR.CH - BtMqttSn, an Arduino library for MQTT-SN over nRF24L01+
//
//-------------------------------------------------------------------------------------------------
//
// Bt::StaticArray
//
//*************************************************************************************************
#ifndef INC__Bt_StaticArray__hpp
#define INC__Bt_StaticArray__hpp
#include <stddef.h>
namespace Bt {
template<typename T, size_t SIZE>
class StaticArray {
public:
typedef T value_type;
typedef T* iterator;
typedef T const * const_iterator;
StaticArray()
: mData() {
}
StaticArray(const T(& pArray)[SIZE])
: mData(pArray) {
}
~StaticArray() {
}
size_t size() const {
return SIZE;
}
const T& operator[](size_t iIndex) const {
return mData[iIndex];
}
T& operator[](size_t iIndex) {
return mData[iIndex];
}
iterator begin() {
return mData;
}
iterator end() {
return mData+SIZE;
}
const_iterator begin() const {
return mData;
}
const_iterator end() const {
return mData+SIZE;
}
private:
//StaticArray(const StaticArray<T,SIZE>& iArray);
//StaticArray& operator=(const StaticArray& iArray);
void copy(const StaticArray<T,SIZE>& iArray) {
for (int i = 0; i < iArray.mSize; ++i) {
mData[i] = iArray[i];
}
}
T mData[SIZE];
};
} // namespace Bt
#endif // INC__Bt_StaticArray__hpp