dl
dl_array2.h
浏览该文件的文档.
1
13#pragma once
14
15
16namespace dl
17{
18
19template<typename T, size_t W, size_t H>
20class Array2
21{
22public:
26 void Fill(const T& v)
27 {
28 for (auto& iter : _data)
29 iter = v;
30 }
31
32 std::byte* GetBuffer()
33 {
34 return (std::byte*)_data.data();
35 }
36
38 {
39 return _data.data();
40 }
41
42 unsigned GetWidth()
43 {
44 return (unsigned)W;
45 }
46
47 unsigned GetHeight()
48 {
49 return (unsigned)H;
50 }
51
53 {
54 return { (unsigned)W, (unsigned)H };
55 }
56
57 size_t GetSizeByte()
58 {
59 return _data.size() * sizeof(T);
60 }
61
62 auto begin()
63 {
64 return _data.begin();
65 }
66 auto end()
67 {
68 return _data.end();
69 }
70private:
71 std::array<T, W * H> _data;
72 std::array<T*, H> _ptrRow;
73};
74
75
76}
void Fill(const T &v)
填充值
Definition: dl_array2.h:26
auto end()
Definition: dl_array2.h:66
unsigned GetHeight()
Definition: dl_array2.h:47
size_t GetSizeByte()
Definition: dl_array2.h:57
auto begin()
Definition: dl_array2.h:62
T * GetData()
Definition: dl_array2.h:37
std::byte * GetBuffer()
Definition: dl_array2.h:32
unsigned GetWidth()
Definition: dl_array2.h:42
Size GetSize()
Definition: dl_array2.h:52
Definition: dl_array2.h:17
PointU Size
Definition: dl_type_def.h:34