Photon Engine
2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TArrayVector.ipp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Utility/TArrayVector.h
"
4
5
#include <Common/assertion.h>
6
#include <Common/config.h>
7
8
#include <utility>
9
#include <type_traits>
10
11
namespace
ph
12
{
13
14
template
<
typename
T, std::
size_t
N>
15
inline
TArrayVector<T, N>::TArrayVector
() :
16
17
#
if
PH_DEBUG
18
// Request value-initialization: set to zeros for primitive types
19
m_data{},
20
#else
21
// Intentionally left empty: default-initialize array members
22
#endif
23
24
m_size(0)
25
{}
26
27
template
<
typename
T, std::
size_t
N>
28
template
<
typename
U>
29
inline
void
TArrayVector<T, N>::pushBack
(U&& item)
30
{
31
// TODO: static assert for U == T, amy require ref and ptr removal
32
33
PH_ASSERT_LT(m_size, m_data.size());
34
35
// FIXME: what if assignment throw? need increment m_size later only if assignment succeeded;
36
// perhaps check if op is no-throw?
37
m_data[m_size++] = std::forward<U>(item);
38
}
39
40
template
<
typename
T, std::
size_t
N>
41
inline
void
TArrayVector<T, N>::popBack
()
42
{
43
PH_ASSERT_GT(m_size, 0);
44
45
--m_size;
46
}
47
48
template
<
typename
T, std::
size_t
N>
49
inline
std::size_t
TArrayVector<T, N>::size
()
const
50
{
51
PH_ASSERT_LE(m_size, N);
52
53
return
m_size;
54
}
55
56
template
<
typename
T, std::
size_t
N>
57
inline
void
TArrayVector<T, N>::clear
()
58
{
59
m_size = 0;
60
}
61
62
template
<
typename
T, std::
size_t
N>
63
inline
bool
TArrayVector<T, N>::isEmpty
()
const
64
{
65
return
m_size == 0;
66
}
67
68
template
<
typename
T, std::
size_t
N>
69
inline
bool
TArrayVector<T, N>::isFull
()
const
70
{
71
return
m_size == N;
72
}
73
74
template
<
typename
T, std::
size_t
N>
75
inline
T*
TArrayVector<T, N>::get
(
const
std::size_t index)
76
{
77
return
index < m_size ? &(m_data[index]) :
nullptr
;
78
}
79
80
template
<
typename
T, std::
size_t
N>
81
inline
const
T*
TArrayVector<T, N>::get
(
const
std::size_t index)
const
82
{
83
return
index < m_size ? &(m_data[index]) :
nullptr
;
84
}
85
86
template
<
typename
T, std::
size_t
N>
87
inline
T&
TArrayVector<T, N>::operator []
(
const
std::size_t index)
88
{
89
PH_ASSERT_LT(index, m_size);
90
91
return
m_data[index];
92
}
93
94
template
<
typename
T, std::
size_t
N>
95
inline
const
T&
TArrayVector<T, N>::operator []
(
const
std::size_t index)
const
96
{
97
PH_ASSERT_LT(index, m_size);
98
99
return
m_data[index];
100
}
101
102
template
<
typename
T, std::
size_t
N>
103
inline
T&
TArrayVector<T, N>::front
()
104
{
105
PH_ASSERT_GT(m_size, 0);
106
107
return
(*
this
)[0];
108
}
109
110
template
<
typename
T, std::
size_t
N>
111
inline
const
T&
TArrayVector<T, N>::front
()
const
112
{
113
PH_ASSERT_GT(m_size, 0);
114
115
return
(*
this
)[0];
116
}
117
118
template
<
typename
T, std::
size_t
N>
119
inline
T&
TArrayVector<T, N>::back
()
120
{
121
PH_ASSERT_GT(m_size, 0);
122
123
return
(*
this
)[m_size - 1];
124
}
125
126
template
<
typename
T, std::
size_t
N>
127
inline
const
T&
TArrayVector<T, N>::back
()
const
128
{
129
PH_ASSERT_GT(m_size, 0);
130
131
return
(*
this
)[m_size - 1];
132
}
133
134
template
<
typename
T, std::
size_t
N>
135
typename
std::array<T, N>::iterator
TArrayVector<T, N>::begin
() noexcept
136
{
137
return
m_data.begin();
138
}
139
140
template
<
typename
T, std::
size_t
N>
141
typename
std::array<T, N>::const_iterator
TArrayVector<T, N>::begin
() const noexcept
142
{
143
return
m_data.begin();
144
}
145
146
template
<
typename
T, std::
size_t
N>
147
typename
std::array<T, N>::iterator
TArrayVector<T, N>::end
() noexcept
148
{
149
// Not using std::advance() as we expect it to be randomly accessible
150
// (no permissive code)
151
return
m_data.begin() + m_size;
152
}
153
154
template
<
typename
T, std::
size_t
N>
155
typename
std::array<T, N>::const_iterator
TArrayVector<T, N>::end
() const noexcept
156
{
157
// Not using std::advance() as we expect it to be randomly accessible
158
// (no permissive code)
159
return
m_data.begin() + m_size;
160
}
161
162
}
// end namespace ph
TArrayVector.h
if
else if(BATCH_SIZE==8)
Definition
TBvhSimdComputingContext.h:505
ph::TArrayVector::begin
std::array< T, N >::iterator begin() noexcept
Definition
TArrayVector.ipp:135
ph::TArrayVector::back
T & back()
Definition
TArrayVector.ipp:119
ph::TArrayVector::pushBack
void pushBack(U &&item)
Add an item to the back of the vector. The item originally at the target index will be overwritten.
Definition
TArrayVector.ipp:29
ph::TArrayVector::operator[]
T & operator[](std::size_t index)
Definition
TArrayVector.ipp:87
ph::TArrayVector::isEmpty
bool isEmpty() const
Definition
TArrayVector.ipp:63
ph::TArrayVector::size
std::size_t size() const
Definition
TArrayVector.ipp:49
ph::TArrayVector::TArrayVector
TArrayVector()
Definition
TArrayVector.ipp:15
ph::TArrayVector::clear
void clear()
Definition
TArrayVector.ipp:57
ph::TArrayVector::popBack
void popBack()
Removes an item from the back of the vector. The item originally at the target index is still alive a...
Definition
TArrayVector.ipp:41
ph::TArrayVector::end
std::array< T, N >::iterator end() noexcept
Definition
TArrayVector.ipp:147
ph::TArrayVector::isFull
bool isFull() const
Definition
TArrayVector.ipp:69
ph::TArrayVector::get
T * get(std::size_t index)
Definition
TArrayVector.ipp:75
ph::TArrayVector::front
T & front()
Definition
TArrayVector.ipp:103
ph
The root for all renderer implementations.
Definition
EEngineProject.h:6
Source
Utility
TArrayVector.ipp
Generated by
1.11.0