1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2005 - 2014 Christian Schoenebeck * |
* Copyright (C) 2005 - 2017 Christian Schoenebeck * |
4 |
* * |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
22 |
#define __LS_ARRAYLIST_H__ |
#define __LS_ARRAYLIST_H__ |
23 |
|
|
24 |
#include "Exception.h" |
#include "Exception.h" |
25 |
|
#include <string.h> // for memcpy() |
26 |
|
|
27 |
namespace LinuxSampler { |
namespace LinuxSampler { |
28 |
|
|
163 |
} |
} |
164 |
|
|
165 |
/** |
/** |
166 |
* Assignment. |
* Generalized assignment with size adjustment and deep copy of |
167 |
|
* elements. Note that this method/operator re-allocates, so it is |
168 |
|
* not appropriate for being used in a real-time context! |
169 |
|
* |
170 |
|
* @see copyFlatFrom() for real-time safe copying |
171 |
*/ |
*/ |
172 |
ArrayList& operator=(const ArrayList& list) { |
ArrayList& operator=(const ArrayList& list) { |
173 |
if (this != &list) { |
if (this != &list) { |
177 |
return *this; |
return *this; |
178 |
} |
} |
179 |
|
|
180 |
|
/** |
181 |
|
* Real-time safe copying elements (flat, no deep copy) from |
182 |
|
* given @a list to this list. |
183 |
|
*/ |
184 |
|
void copyFlatFrom(const ArrayList& list) { |
185 |
|
const int n = (size() < list.size()) ? size() : list.size(); |
186 |
|
memcpy(pData, list.pData, n * sizeof(T)); |
187 |
|
} |
188 |
|
|
189 |
private: |
private: |
190 |
T* pData; |
T* pData; |
191 |
int iSize; |
int iSize; |