forked from sshekh/conv-filters
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNDGrid.hpp
More file actions
56 lines (41 loc) · 1.08 KB
/
NDGrid.hpp
File metadata and controls
56 lines (41 loc) · 1.08 KB
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
/*
* Build obj linking with cc_library NDGrid Class.
*
* Copyright Bazel organization
*
*/
#ifndef CH04_SIMPLENET_MAIN_NDGRID_H_
#define CH04_SIMPLENET_MAIN_NDGRID_H_
#include <vector>
#include <optional>
#include <cstddef>
template <typename T, size_t N>
class NDGrid
{
public:
explicit NDGrid(size_t size = kDefaultSize);
virtual ~NDGrid() = default;
NDGrid<T, N-1>& operator[](size_t x);
const NDGrid<T, N-1>& operator[](size_t x) const;
void resize(size_t newSize);
size_t getSize() const { return mElements.size(); }
static const size_t kDefaultSize = 512;
private:
std::vector<NDGrid<T, N-1>> mElements;
};
template <typename T>
class NDGrid<T, 1>
{
public:
explicit NDGrid(size_t size = kDefaultSize);
virtual ~NDGrid() = default;
T& operator[](size_t x);
const T& operator[](size_t x) const;
void resize(size_t newSize);
size_t getSize() const { return mElements.size(); }
static const size_t kDefaultSize = 512;
private:
std::vector<T> mElements;
};
#include "NDGrid.cc"
#endif // CH04_SIMPLENET_MAIN_NDGRID_H_