40 #ifndef DUMBVECTOR_HPP
41 #define DUMBVECTOR_HPP 1
45 #include "R_ext/Error.h"
59 template <
typename T, SEXPTYPE ST>
83 m_singleton(initializer)
85 if (sz > 1) allocData(sz,
true);
101 return m_data[index];
111 return m_data[index];
135 if (m_data != &m_singleton)
153 void allocData(
size_t sz,
bool initialize =
false);
156 template <
typename T, SEXPTYPE ST>
159 m_singleton(pattern.m_singleton)
164 memcpy(m_data, pattern.m_data,
sizeof(T)*sz);
168 template <
typename T, SEXPTYPE ST>
171 size_t bytes = sz*
sizeof(T);
173 if (bytes/
sizeof(T) != sz)
174 Rf_error(_(
"Request to create impossibly large vector."));
177 for (
unsigned int i = 0; i < sz; ++i)
178 m_data[i] = m_singleton;
182 template <
typename T, SEXPTYPE ST>
188 template <
typename T, SEXPTYPE ST>
195 #endif // DUMBVECTOR_HPP