Loading...
Searching...
No Matches
Array.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_HPP
12#define CUBBYFLOW_ARRAY_HPP
13
15
16#include <vector>
17
18namespace CubbyFlow
19{
31template <typename T, size_t N>
32class ArrayView;
33
34template <typename T, size_t N>
35class Array final : public ArrayBase<T, N, Array<T, N>>
36{
38 using Base::At;
40 using Base::m_size;
43
44 public:
45 Array();
46
47 Array(const Vector<size_t, N>& size, const T& initVal = T{});
48
49 template <typename... Args>
50 Array(size_t nx, Args... args);
51
53
54 template <typename OtherDerived>
56
57 template <typename OtherDerived>
59
60 ~Array() override = default;
61
62 Array(const Array& other);
63
64 Array(Array&& other) noexcept;
65
66 Array& operator=(const Array& other);
67
68 Array& operator=(Array&& other) noexcept;
69
70 template <typename OtherDerived>
72
73 template <typename OtherDerived>
75
76 template <typename D>
78
79 template <typename D>
81
82 void Fill(const T& val);
83
84 void Resize(Vector<size_t, N> size_, const T& initVal = T{});
85
86 template <typename... Args>
87 void Resize(size_t nx, Args... args);
88
89 template <size_t M = N>
90 std::enable_if_t<(M == 1), void> Append(const T& val);
91
92 template <typename OtherDerived, size_t M = N>
93 std::enable_if_t<(M == 1), void> Append(
95
96 template <typename OtherDerived, size_t M = N>
97 std::enable_if_t<(M == 1), void> Append(
99
100 void Clear();
101
102 void Swap(Array& other);
103
105
107
108 private:
109 std::vector<T> m_data;
110};
111
112template <class T>
114
115template <class T>
117
118template <class T>
120
121template <class T>
123} // namespace CubbyFlow
124
126
127#endif
Definition ArrayBase.hpp:20
void ClearPtrAndSize()
Definition ArrayBase-Impl.hpp:263
Vector< size_t, N > m_size
Definition ArrayBase.hpp:125
void SetPtrAndSize(Pointer ptr, size_t ni, Args... args)
Definition ArrayBase-Impl.hpp:250
void SwapPtrAndSize(ArrayBase &other)
Definition ArrayBase-Impl.hpp:269
Reference At(size_t i)
Definition ArrayBase-Impl.hpp:138
Definition Array.hpp:36
void CopyFrom(const ArrayBase< T, N, D > &other)
Definition Array-Impl.hpp:263
void Resize(Vector< size_t, N > size_, const T &initVal=T{})
Definition Array-Impl.hpp:286
ArrayView< T, N > View()
Definition Array-Impl.hpp:355
std::enable_if_t<(M==1), void > Append(const T &val)
Definition Array-Impl.hpp:311
Array & operator=(const Array &other)
Definition Array-Impl.hpp:224
~Array() override=default
Array()
Definition Array-Impl.hpp:162
void Swap(Array &other)
Definition Array-Impl.hpp:347
void Fill(const T &val)
Definition Array-Impl.hpp:280
Array & operator=(const ArrayBase< T, N, OtherDerived > &other)
void Clear()
Definition Array-Impl.hpp:339
Array & operator=(const ArrayBase< const T, N, OtherDerived > &other)
Definition Matrix.hpp:30
Definition pybind11Utils.hpp:21
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738