Loading...
Searching...
No Matches
ArrayView-Impl.hpp
Go to the documentation of this file.
1// This code is based on Jet framework.
2// Copyright (c) 2018 Doyub Kim
3// CubbyFlow is voxel-based fluid simulation engine for computer games.
4// Copyright (c) 2020 CubbyFlow Team
5// Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6// AI Part: Dongheon Cho, Minseo Kim
7// We are making my contributions/submissions to this project solely in our
8// personal capacity and are not conveying any rights to any intellectual
9// property of any third parties.
10
11#ifndef CUBBYFLOW_ARRAY_VIEW_IMPL_HPP
12#define CUBBYFLOW_ARRAY_VIEW_IMPL_HPP
13
14#include <Core/Array/Array.hpp>
15
16namespace CubbyFlow
17{
18template <typename T, size_t N>
20{
21 // Do nothing
22}
23
24template <typename T, size_t N>
29
30template <typename T, size_t N>
31template <size_t M>
32ArrayView<T, N>::ArrayView(std::enable_if_t<(M == 1), T*> ptr, size_t size)
34{
35 // Do nothing
36}
37
38template <typename T, size_t N>
43
44template <typename T, size_t N>
47 Set(other);
49
50template <typename T, size_t N>
53 *this = std::move(other);
55
56template <typename T, size_t N>
58{
59 Set(other);
60
61 return *this;
62}
63
64template <typename T, size_t N>
66{
67 Base::SetPtrAndSize(other.data(), other.Size());
68 other.SetPtrAndSize(nullptr, Vector<size_t, N>{});
69
70 return *this;
71}
72
73template <typename T, size_t N>
75{
76 Base::SetPtrAndSize(other.data(), other.Size());
77}
78
79template <typename T, size_t N>
81{
82 Base::SetPtrAndSize(const_cast<T*>(other.data()), other.Size());
83}
84
85template <typename T, size_t N>
87{
89 [&](auto... idx) { this->At(idx...) = val; });
90}
91
92template <typename T, size_t N>
94{
95 // Do nothing
96}
97
98template <typename T, size_t N>
100 : ArrayView()
101{
103}
104
105template <typename T, size_t N>
106template <size_t M>
107ArrayView<const T, N>::ArrayView(const std::enable_if_t<(M == 1), T*> ptr,
108 size_t size)
110{
111 // Do nothing
112}
113
114template <typename T, size_t N>
116{
117 Set(other);
118}
119
120template <typename T, size_t N>
122{
123 Set(other);
124}
125
126template <typename T, size_t N>
127ArrayView<const T, N>::ArrayView(const ArrayView<const T, N>& other)
128{
129 Set(other);
130}
131
132template <typename T, size_t N>
133ArrayView<const T, N>::ArrayView(ArrayView&& other) noexcept : ArrayView()
134{
135 *this = std::move(other);
136}
137
138template <typename T, size_t N>
139ArrayView<const T, N>& ArrayView<const T, N>::operator=(
140 const ArrayView<T, N>& other)
141{
142 Set(other);
143
144 return *this;
145}
146
147template <typename T, size_t N>
148ArrayView<const T, N>& ArrayView<const T, N>::operator=(
149 const ArrayView<const T, N>& other)
150{
151 Set(other);
152
153 return *this;
154}
155
156template <typename T, size_t N>
157ArrayView<const T, N>& ArrayView<const T, N>::operator=(
158 ArrayView<const T, N>&& other) noexcept
159{
160 Base::SetPtrAndSize(other.data(), other.Size());
161 other.SetPtrAndSize(nullptr, Vector<size_t, N>{});
162
163 return *this;
164}
165
166template <typename T, size_t N>
168{
169 Base::SetPtrAndSize(other.data(), other.Size());
170}
171
172template <typename T, size_t N>
174{
175 Base::SetPtrAndSize(other.data(), other.Size());
176}
177
178template <typename T, size_t N>
179void ArrayView<const T, N>::Set(const ArrayView<const T, N>& other)
180{
181 Base::SetPtrAndSize(other.data(), other.Size());
182}
183} // namespace CubbyFlow
184
185#endif
void SetPtrAndSize(Pointer ptr, size_t ni, Args... args)
Definition ArrayBase-Impl.hpp:250
Generic N-dimensional array class interface.
Definition ArrayView.hpp:26
ArrayView()
Definition ArrayView-Impl.hpp:19
void Set(Array< T, N > &other)
Definition ArrayView-Impl.hpp:74
void Fill(const T &val)
Definition ArrayView-Impl.hpp:86
ArrayView & operator=(const ArrayView &other)
Definition ArrayView-Impl.hpp:57
Definition Matrix.hpp:30
Pointer data()
Definition Matrix-Impl.hpp:298
Definition pybind11Utils.hpp:21
void ForEachIndex(const Vector< IndexType, N > &begin, const Vector< IndexType, N > &end, const Func &func)
Definition IterationUtils-Impl.hpp:51
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738