39template <
class ElementType,
class TypeOfCriticalSectionToUse>
45 template <
class OtherElementType,
class OtherCriticalSection>
46 using AllowConversion =
typename std::enable_if<! std::is_same<std::tuple<ElementType, TypeOfCriticalSectionToUse>,
47 std::tuple<OtherElementType, OtherCriticalSection>>
::value>
::type;
59 :
elements (std::move (other.elements)),
63 other.numAllocated = 0;
71 auto tmp (std::move (other));
83 template <
class OtherElementType,
84 class OtherCriticalSection,
85 typename = AllowConversion<OtherElementType, OtherCriticalSection>>
87 :
elements (std::move (other.elements)),
91 other.numAllocated = 0;
100 template <
class OtherElementType,
101 class OtherCriticalSection,
102 typename = AllowConversion<OtherElementType, OtherCriticalSection>>
106 elements = std::move (other.elements);
110 other.numAllocated = 0;
117 template <
class OtherArrayType>
118 bool operator== (
const OtherArrayType& other)
const noexcept
120 if (
size() != (
int) other.size())
125 for (
auto& o : other)
132 template <
class OtherArrayType>
133 bool operator!= (
const OtherArrayType& other)
const noexcept
135 return ! operator== (other);
139 inline ElementType& operator[] (
const int index)
noexcept
146 inline const ElementType& operator[] (
const int index)
const noexcept
252 std::swap (
numUsed, other.numUsed);
256 void add (
const ElementType& newElement)
261 void add (ElementType&& newElement)
263 addImpl (std::move (newElement));
266 template <
typename... OtherElements>
267 void add (
const ElementType& firstNewElement, OtherElements&&... otherElements)
269 addImpl (firstNewElement, std::forward<OtherElements> (otherElements)...);
272 template <
typename... OtherElements>
273 void add (ElementType&& firstNewElement, OtherElements&&... otherElements)
275 addImpl (std::move (firstNewElement), std::forward<OtherElements> (otherElements)...);
279 template <
typename Type>
280 void addArray (
const Type* elementsToAdd,
int numElementsToAdd)
287 template <
typename TypeToCreateFrom>
288 void addArray (
const std::initializer_list<TypeToCreateFrom>& items)
292 for (
auto& item : items)
296 template <
class OtherArrayType>
297 void addArray (
const OtherArrayType& arrayToAddFrom)
299 jassert ((
const void*)
this != (
const void*) &arrayToAddFrom);
302 for (
auto&
e : arrayToAddFrom)
306 template <
class OtherArrayType>
307 typename std::enable_if<! std::is_pointer<OtherArrayType>::value,
int>
::type
309 int startIndex,
int numElementsToAdd = -1)
311 jassert ((
const void*)
this != (
const void*) &arrayToAddFrom);
319 if (numElementsToAdd < 0 || startIndex + numElementsToAdd > (
int) arrayToAddFrom.size())
320 numElementsToAdd = (
int) arrayToAddFrom.size() - startIndex;
322 addArray (arrayToAddFrom.data() + startIndex, numElementsToAdd);
324 return numElementsToAdd;
333 for (
int i = 0;
i < numberOfTimesToInsertIt; ++
i)
334 new (space++) ElementType (newElement);
336 numUsed += numberOfTimesToInsertIt;
339 void insertArray (
int indexToInsertAt,
const ElementType* newElements,
int numberOfElements)
343 for (
int i = 0;
i < numberOfElements; ++
i)
344 new (space++) ElementType (*(newElements++));
352 jassert (indexToRemoveAt >= 0);
353 jassert (numElementsToRemove >= 0);
356 if (numElementsToRemove > 0)
359 numUsed -= numElementsToRemove;
364 void swap (
int index1,
int index2)
375 void move (
int currentIndex,
int newIndex)
noexcept
388 template <
typename T>
389 #if defined(__GNUC__) && __GNUC__ < 5 && ! defined(__clang__)
390 using IsTriviallyCopyable = std::is_scalar<T>;
395 template <
typename T>
398 template <
typename T>
402 template <
typename T = ElementType>
409 template <
typename Type,
typename T = ElementType>
414 while (--numElements >= 0)
415 new (
start++) ElementType (*(otherElements++));
418 template <
typename Type,
typename T = ElementType>
423 while (--numElements >= 0)
424 new (
start++) ElementType (*(otherElements++));
428 template <
typename T = ElementType>
431 elements.realloc ((
size_t) numElements);
434 template <
typename T = ElementType>
441 new (newElements +
i) ElementType (std::move (
elements[
i]));
461 template <
typename T = ElementType>
465 auto numElementsToShift =
numUsed - indexToInsertAt;
466 memmove (
start + numElements,
start, (
size_t) numElementsToShift *
sizeof (ElementType));
469 template <
typename T = ElementType>
473 auto* newEnd =
end + numElements;
474 auto numElementsToShift =
numUsed - indexToInsertAt;
476 for (
int i = 0;
i < numElementsToShift; ++
i)
478 new (--newEnd) ElementType (std::move (*(--
end)));
484 template <
typename T = ElementType>
488 auto numElementsToShift =
numUsed - (indexToRemoveAt + numElementsToRemove);
489 memmove (
start,
start + numElementsToRemove, (
size_t) numElementsToShift *
sizeof (ElementType));
492 template <
typename T = ElementType>
495 auto numElementsToShift =
numUsed - (indexToRemoveAt + numElementsToRemove);
496 auto* destination =
elements + indexToRemoveAt;
497 auto* source = destination + numElementsToRemove;
499 for (
int i = 0;
i < numElementsToShift; ++
i)
502 for (
int i = 0;
i < numElementsToRemove; ++
i)
503 (destination++)->~ElementType();
507 template <
typename T = ElementType>
510 char tempCopy[
sizeof (ElementType)];
513 if (newIndex > currentIndex)
517 (
size_t) (newIndex - currentIndex) *
sizeof (ElementType));
523 (
size_t) (currentIndex - newIndex) *
sizeof (ElementType));
529 template <
typename T = ElementType>
533 ElementType tempCopy (std::move (*
e));
534 auto delta = newIndex - currentIndex;
538 for (
int i = 0;
i < delta; ++
i)
546 for (
int i = 0;
i < -delta; ++
i)
557 template <
typename... Elements>
565 template <
typename... Elements>
572 template <
typename T = ElementType>
573 typename std::enable_if<std::is_move_assignable<T>::value,
void>
::type
576 *destination = std::move (source);
579 template <
typename T = ElementType>
580 typename std::enable_if<! std::is_move_assignable<T>::value,
void>
::type
583 destination->~ElementType();
584 new (destination) ElementType (std::move (source));
601 template <
class OtherElementType,
class OtherCriticalSection>
#define noexcept
Definition DistrhoDefines.h:72
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
ElementType getLast() const noexcept
Definition juce_ArrayBase.h:163
void add(const ElementType &newElement)
Definition juce_ArrayBase.h:256
ElementType getFirst() const noexcept
Definition juce_ArrayBase.h:158
ArrayBase(ArrayBase &&other) noexcept
Definition juce_ArrayBase.h:58
NonTriviallyCopyableVoid< T > addArrayInternal(const Type *otherElements, int numElements)
Definition juce_ArrayBase.h:419
typename std::enable_if< IsTriviallyCopyable< T >::value, void >::type TriviallyCopyableVoid
Definition juce_ArrayBase.h:396
std::enable_if<!std::is_pointer< OtherArrayType >::value, int >::type addArray(const OtherArrayType &arrayToAddFrom, int startIndex, int numElementsToAdd=-1)
Definition juce_ArrayBase.h:308
int numUsed
Definition juce_ArrayBase.h:599
friend class ArrayBase
Definition juce_ArrayBase.h:602
NonTriviallyCopyableVoid< T > removeElementsInternal(int indexToRemoveAt, int numElementsToRemove)
Definition juce_ArrayBase.h:493
HeapBlock< ElementType > elements
Definition juce_ArrayBase.h:598
void setAllocatedSize(int numElements)
Definition juce_ArrayBase.h:210
TriviallyCopyableVoid< T > addArrayInternal(const Type *otherElements, int numElements)
Definition juce_ArrayBase.h:410
std::is_trivially_copyable< T > IsTriviallyCopyable
Definition juce_ArrayBase.h:392
void addArray(const Type *elementsToAdd, int numElementsToAdd)
Definition juce_ArrayBase.h:280
ElementType * data() noexcept
Definition juce_ArrayBase.h:189
typename std::enable_if<! IsTriviallyCopyable< T >::value, void >::type NonTriviallyCopyableVoid
Definition juce_ArrayBase.h:399
typename std::enable_if<! std::is_same< std::tuple< ElementType, TypeOfCriticalSectionToUse >, std::tuple< OtherElementType, OtherCriticalSection > >::value >::type AllowConversion
Definition juce_ArrayBase.h:46
void swap(int index1, int index2)
Definition juce_ArrayBase.h:364
ArrayBase(ArrayBase< OtherElementType, OtherCriticalSection > &&other) noexcept
Definition juce_ArrayBase.h:86
void add(ElementType &&newElement)
Definition juce_ArrayBase.h:261
std::enable_if< std::is_move_assignable< T >::value, void >::type moveAssignElement(ElementType *destination, ElementType &&source)
Definition juce_ArrayBase.h:574
~ArrayBase()
Definition juce_ArrayBase.h:53
void insert(int indexToInsertAt, ParameterType newElement, int numberOfTimesToInsertIt)
Definition juce_ArrayBase.h:328
void add(ElementType &&firstNewElement, OtherElements &&... otherElements)
Definition juce_ArrayBase.h:273
ElementType * begin() noexcept
Definition juce_ArrayBase.h:169
void insertArray(int indexToInsertAt, const ElementType *newElements, int numberOfElements)
Definition juce_ArrayBase.h:339
void addImpl(Elements &&... toAdd)
Definition juce_ArrayBase.h:558
ElementType getValueWithDefault(const int index) const noexcept
Definition juce_ArrayBase.h:153
void swapWith(ArrayBase &other) noexcept
Definition juce_ArrayBase.h:248
void checkSourceIsNotAMember(const ElementType &element)
Definition juce_ArrayBase.h:587
void removeElements(int indexToRemoveAt, int numElementsToRemove)
Definition juce_ArrayBase.h:350
typename TypeHelpers::ParameterType< ElementType >::type ParameterType
Definition juce_ArrayBase.h:43
TriviallyCopyableVoid< T > createInsertSpaceInternal(int indexToInsertAt, int numElements)
Definition juce_ArrayBase.h:462
void addArray(const std::initializer_list< TypeToCreateFrom > &items)
Definition juce_ArrayBase.h:288
TriviallyCopyableVoid< T > setAllocatedSizeInternal(int numElements)
Definition juce_ArrayBase.h:429
int size() const noexcept
Definition juce_ArrayBase.h:199
void move(int currentIndex, int newIndex) noexcept
Definition juce_ArrayBase.h:375
int numAllocated
Definition juce_ArrayBase.h:599
TriviallyCopyableVoid< T > removeElementsInternal(int indexToRemoveAt, int numElementsToRemove)
Definition juce_ArrayBase.h:485
const ElementType * begin() const noexcept
Definition juce_ArrayBase.h:174
int capacity() const noexcept
Definition juce_ArrayBase.h:204
void addArray(const OtherArrayType &arrayToAddFrom)
Definition juce_ArrayBase.h:297
const ElementType * end() const noexcept
Definition juce_ArrayBase.h:184
void add(const ElementType &firstNewElement, OtherElements &&... otherElements)
Definition juce_ArrayBase.h:267
void ensureAllocatedSize(int minNumElements)
Definition juce_ArrayBase.h:225
TriviallyCopyableVoid< T > addArrayInternal(const ElementType *otherElements, int numElements)
Definition juce_ArrayBase.h:403
const ElementType * data() const noexcept
Definition juce_ArrayBase.h:194
NonTriviallyCopyableVoid< T > moveInternal(int currentIndex, int newIndex) noexcept
Definition juce_ArrayBase.h:530
ElementType * createInsertSpace(int indexToInsertAt, int numElements)
Definition juce_ArrayBase.h:449
NonTriviallyCopyableVoid< T > setAllocatedSizeInternal(int numElements)
Definition juce_ArrayBase.h:435
std::enable_if<!std::is_move_assignable< T >::value, void >::type moveAssignElement(ElementType *destination, ElementType &&source)
Definition juce_ArrayBase.h:581
NonTriviallyCopyableVoid< T > createInsertSpaceInternal(int indexToInsertAt, int numElements)
Definition juce_ArrayBase.h:470
ElementType * end() noexcept
Definition juce_ArrayBase.h:179
TriviallyCopyableVoid< T > moveInternal(int currentIndex, int newIndex) noexcept
Definition juce_ArrayBase.h:508
void clear()
Definition juce_ArrayBase.h:239
void addAssumingCapacityIsReady(Elements &&... toAdd)
Definition juce_ArrayBase.h:566
void shrinkToNoMoreThan(int maxNumElements)
Definition juce_ArrayBase.h:233
Definition juce_HeapBlock.h:87
* e
Definition inflate.c:1404
register unsigned i
Definition inflate.c:1575
static PuglViewHint int value
Definition pugl.h:1708
virtual ASIOError start()=0
Definition carla_juce.cpp:31
void ignoreUnused(Types &&...) noexcept
Definition juce_MathsFunctions.h:333
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Definition juce_MathsFunctions.h:279
const Type & type
Definition juce_MathsFunctions.h:632
memcpy(hh, h, RAND_HEAD_LEN)
typedef int(UZ_EXP MsgFn)()
#define void
Definition unzip.h:396
#define const
Definition zconf.h:137