10 #ifndef G3D_SmallArray_h
11 #define G3D_SmallArray_h
22 template<
class T,
int N>
41 void resize(
int n,
bool shrinkIfNecessary =
true) {
46 void clear(
bool shrinkIfNecessary =
true) {
47 resize(0, shrinkIfNecessary);
73 inline void push(
const T& v) {
76 m_embedded[m_size - 1] = v;
86 inline void append(
const T& v,
const T& v2) {
91 inline void append(
const T& v,
const T& v2,
const T& v3) {
97 inline void append(
const T& v,
const T& v2,
const T& v3,
const T& v4) {
106 for (
int i = 0; i < N; ++i) {
107 if (m_embedded[i] == v) {
120 m_embedded[i] = m_embedded[m_size - 1];
123 m_embedded[i] = m_rest.
pop();
137 return m_embedded[
m_size];
156 return m_embedded[m_size - 1];
158 return m_rest.
next();
163 for (
int i =
std::min(m_size, N) - 1; i >= 0; --i) {
164 if (m_embedded[i] == value) {
171 template<
int MIN_ELEMENTS>
174 for (
int i = 0; i < src.
size(); ++i) {
181 return (*
this)[
size() - 1];
185 return (*
this)[
size() - 1];
void fastRemove(int i, bool shrinkIfNecessary=false)
Definition: SmallArray.h:115
T pop(bool shrinkUnderlyingArrayIfNecessary=true)
Definition: Array.h:837
T m_embedded[N]
Definition: SmallArray.h:28
T & last()
Definition: SmallArray.h:184
void resize(size_t n, bool shrinkIfNecessary=true)
Definition: Array.h:490
Definition: SmallArray.h:23
SmallArray< T, N > & operator=(const Array< T, MIN_ELEMENTS > &src)
Definition: SmallArray.h:172
bool contains(const T &value) const
Definition: SmallArray.h:162
void clear(bool shrinkIfNecessary=true)
Definition: SmallArray.h:46
int findIndex(const T &v)
Definition: SmallArray.h:105
T & next()
Definition: SmallArray.h:153
void popDiscard()
Definition: SmallArray.h:145
shared_ptr< class MemoryManager > Ref
Definition: MemoryManager.h:31
void popDiscard(bool shrinkUnderlyingArrayIfNecessary=false)
Definition: Array.h:846
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T & next()
Definition: Array.h:762
void clearAndSetMemoryManager(MemoryManager::Ref &m)
Definition: SmallArray.h:50
T min(const T &x, const T &y)
Definition: g3dmath.h:305
void fastRemove(int index, bool shrinkIfNecessary=false)
Definition: Array.h:446
void resize(int n, bool shrinkIfNecessary=true)
Definition: SmallArray.h:41
const T & last() const
Definition: SmallArray.h:180
#define debugAssert(exp)
Definition: debugAssert.h:160
const T & operator[](int i) const
Definition: SmallArray.h:64
SmallArray()
Definition: SmallArray.h:35
T pop()
Definition: SmallArray.h:132
void append(const T &v)
Definition: SmallArray.h:82
void clearAndSetMemoryManager(const MemoryManager::Ref &m)
Definition: Array.h:411
int size() const
Definition: Array.h:430
bool contains(const T &e) const
Definition: Array.h:732
int findIndex(const T &value) const
Definition: Array.h:1009
void append(const T &v, const T &v2)
Definition: SmallArray.h:86
int size() const
Definition: SmallArray.h:37
T & operator[](int i)
Definition: SmallArray.h:55
Array< T > m_rest
Definition: SmallArray.h:31
const FieldDescriptor value
Definition: descriptor.h:1522
void append(const T &value)
Definition: Array.h:583
void append(const T &v, const T &v2, const T &v3)
Definition: SmallArray.h:91
int m_size
Definition: SmallArray.h:25
void append(const T &v, const T &v2, const T &v3, const T &v4)
Definition: SmallArray.h:97
void push(const T &v)
Definition: SmallArray.h:73