52template <
typename ElementType,
53 typename TypeOfCriticalSectionToUse = DummyCriticalSection,
54 int minimumAllocatedSize = 0>
75 :
values (std::move (other.values))
82 template <
typename TypeToCreateFrom>
85 while (*
values != TypeToCreateFrom())
93 template <
typename TypeToCreateFrom>
100 Array (
const ElementType& singleElementToAdd)
102 add (singleElementToAdd);
106 Array (ElementType&& singleElementToAdd)
108 add (std::move (singleElementToAdd));
112 template <
typename... OtherElements>
113 Array (
const ElementType& firstNewElement, OtherElements&&... otherElements)
115 values.add (firstNewElement, std::forward<OtherElements> (otherElements)...);
119 template <
typename... OtherElements>
120 Array (ElementType&& firstNewElement, OtherElements&&... otherElements)
122 values.add (std::move (firstNewElement), std::forward<OtherElements> (otherElements)...);
125 template <
typename TypeToCreateFrom>
126 Array (
const std::initializer_list<TypeToCreateFrom>& items)
141 auto otherCopy (other);
151 values = std::move (other.values);
161 template <
class OtherArrayType>
162 bool operator== (
const OtherArrayType& other)
const
165 const typename OtherArrayType::ScopedLockType lock2 (other.getLock());
174 template <
class OtherArrayType>
175 bool operator!= (
const OtherArrayType& other)
const
177 return ! operator== (other);
192 values.setAllocatedSize (0);
209 for (
auto&
e : *
this)
237 ElementType operator[] (
int index)
const
240 return values.getValueWithDefault (index);
386 auto endPtr =
values.end();
388 for (;
e != endPtr; ++
e)
389 if (elementToLookFor == *
e)
390 return static_cast<int> (
e -
values.begin());
404 auto endPtr =
values.end();
406 for (;
e != endPtr; ++
e)
407 if (elementToLookFor == *
e)
418 void add (
const ElementType& newElement)
428 void add (ElementType&& newElement)
431 values.add (std::move (newElement));
435 template <
typename... OtherElements>
436 void add (
const ElementType& firstNewElement, OtherElements&&... otherElements)
439 values.add (firstNewElement, std::forward<OtherElements> (otherElements)...);
443 template <
typename... OtherElements>
444 void add (ElementType&& firstNewElement, OtherElements&&... otherElements)
447 values.add (std::move (firstNewElement), std::forward<OtherElements> (otherElements)...);
465 values.insert (indexToInsertAt, newElement, 1);
481 int numberOfTimesToInsertIt)
483 if (numberOfTimesToInsertIt > 0)
486 values.insert (indexToInsertAt, newElement, numberOfTimesToInsertIt);
503 const ElementType* newElements,
504 int numberOfElements)
506 if (numberOfElements > 0)
509 values.insertArray (indexToInsertAt, newElements, numberOfElements);
544 if (indexToChange >= 0)
548 if (indexToChange <
values.size())
549 values[indexToChange] = newValue;
572 values[indexToChange] = newValue;
582 template <
typename Type>
583 void addArray (
const Type* elementsToAdd,
int numElementsToAdd)
587 if (numElementsToAdd > 0)
588 values.addArray (elementsToAdd, numElementsToAdd);
591 template <
typename TypeToCreateFrom>
592 void addArray (
const std::initializer_list<TypeToCreateFrom>& items)
604 template <
typename Type>
609 for (
auto e = elementsToAdd; *
e !=
nullptr; ++
e)
620 template <
class OtherArrayType>
621 void swapWith (OtherArrayType& otherArray)
noexcept
624 const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
625 values.swapWith (otherArray.values);
633 template <
class OtherArrayType>
634 void addArray (
const OtherArrayType& arrayToAddFrom)
636 const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock());
639 values.addArray (arrayToAddFrom);
651 template <
class OtherArrayType>
652 typename std::enable_if<! std::is_pointer<OtherArrayType>::value,
void>
::type
655 int numElementsToAdd = -1)
657 const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock());
660 values.addArray (arrayToAddFrom, startIndex, numElementsToAdd);
673 auto numToAdd = targetNumItems -
values.size();
677 else if (numToAdd < 0)
693 template <
class ElementComparator>
698 insert (index, newElement);
713 DefaultElementComparator <ElementType> comparator;
729 template <
typename ElementComparator,
typename TargetValueType>
730 int indexOfSorted (ElementComparator& comparator, TargetValueType elementToLookFor)
const
737 for (
int s = 0,
e =
values.size();;)
742 if (comparator.compareElements (elementToLookFor,
values[
s]) == 0)
745 auto halfway = (
s +
e) / 2;
750 if (comparator.compareElements (elementToLookFor,
values[halfway]) >= 0)
791 ElementType removed (
values[indexToRemove]);
796 return ElementType();
809 void remove (
const ElementType* elementToRemove)
811 jassert (elementToRemove !=
nullptr);
815 auto indexToRemove = (
int) (elementToRemove -
values.begin());
842 if (valueToRemove ==
e[
i])
866 for (
int i =
values.size(); --
i >= 0;)
868 if (valueToRemove ==
values[
i])
889 template <
typename PredicateType>
895 for (
int i =
values.size(); --
i >= 0;)
923 auto endIndex =
jlimit (0,
values.size(), startIndex + numberToRemove);
925 numberToRemove = endIndex - startIndex;
927 if (numberToRemove > 0)
929 values.removeElements (startIndex, numberToRemove);
941 jassert (howManyToRemove >= 0);
943 if (howManyToRemove > 0)
947 if (howManyToRemove >
values.size())
948 howManyToRemove =
values.size();
950 values.removeElements (
values.size() - howManyToRemove, howManyToRemove);
960 template <
class OtherArrayType>
963 const typename OtherArrayType::ScopedLockType lock1 (otherArray.getLock());
966 if (
this == &otherArray)
972 if (otherArray.size() > 0)
974 for (
int i =
values.size(); --
i >= 0;)
975 if (otherArray.contains (
values[
i]))
988 template <
class OtherArrayType>
991 const typename OtherArrayType::ScopedLockType lock1 (otherArray.getLock());
994 if (
this != &otherArray)
996 if (otherArray.size() <= 0)
1002 for (
int i =
values.size(); --
i >= 0;)
1003 if (! otherArray.contains (
values[
i]))
1020 values.swap (index1, index2);
1037 void move (
int currentIndex,
int newIndex)
noexcept
1039 if (currentIndex != newIndex)
1042 values.move (currentIndex, newIndex);
1068 values.ensureAllocatedSize (minNumElements);
1108 template <
class ElementComparator>
1109 void sort (ElementComparator& comparator,
1110 bool retainOrderOfEquivalentItems =
false)
1131 [[deprecated (
"This method has been replaced by a more flexible templated version and renamed "
1132 "to swapWith to be more consistent with the names used in other classes.")]]
1142 values.removeElements (indexToRemove, 1);
1149 values.shrinkToNoMoreThan (
jmax (
values.size(),
jmax (minimumAllocatedSize, 64 / (
int)
sizeof (ElementType))));
#define noexcept
Definition DistrhoDefines.h:72
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
Definition juce_ArrayBase.h:41
int removeIf(PredicateType &&predicate)
Definition juce_Array.h:890
void swapWith(OtherArrayType &otherArray) noexcept
Definition juce_Array.h:621
void add(ElementType &&newElement)
Definition juce_Array.h:428
void setUnchecked(int indexToChange, ParameterType newValue)
Definition juce_Array.h:568
typename DummyCriticalSection::ScopedLockType ScopedLockType
Definition juce_Array.h:1126
void addNullTerminatedArray(const Type *const *elementsToAdd)
Definition juce_Array.h:605
ElementType getUnchecked(int index) const
Definition juce_Array.h:252
void insertArray(int indexToInsertAt, const ElementType *newElements, int numberOfElements)
Definition juce_Array.h:502
bool isEmpty() const noexcept
Definition juce_Array.h:222
void removeLast(int howManyToRemove=1)
Definition juce_Array.h:939
Array(const ElementType &firstNewElement, OtherElements &&... otherElements)
Definition juce_Array.h:113
void ensureStorageAllocated(int minNumElements)
Definition juce_Array.h:1065
void remove(const ElementType *elementToRemove)
Definition juce_Array.h:809
Array(Array &&other) noexcept
Definition juce_Array.h:74
const TypeOfCriticalSectionToUse & getLock() const noexcept
Definition juce_Array.h:1123
void addArray(const Type *elementsToAdd, int numElementsToAdd)
Definition juce_Array.h:583
Array(const TypeToCreateFrom *data)
Definition juce_Array.h:83
void clearQuick()
Definition juce_Array.h:198
void sort()
Definition juce_Array.h:1076
int removeAllInstancesOf(ParameterType valueToRemove)
Definition juce_Array.h:861
Array(const TypeToCreateFrom *data, int numValues)
Definition juce_Array.h:94
Array(const std::initializer_list< TypeToCreateFrom > &items)
Definition juce_Array.h:126
int size() const noexcept
Definition juce_Array.h:215
int removeFirstMatchingValue(ParameterType valueToRemove)
Definition juce_Array.h:835
typename TypeHelpers::ParameterType< ElementType >::type ParameterType
Definition juce_Array.h:58
void fill(const ParameterType &newValue) noexcept
Definition juce_Array.h:205
void addArray(const std::initializer_list< TypeToCreateFrom > &items)
Definition juce_Array.h:592
void removeRange(int startIndex, int numberToRemove)
Definition juce_Array.h:919
void removeValuesIn(const OtherArrayType &otherArray)
Definition juce_Array.h:961
const ElementType * end() const noexcept
Definition juce_Array.h:352
void remove(int indexToRemove)
Definition juce_Array.h:767
void insert(int indexToInsertAt, ParameterType newElement)
Definition juce_Array.h:462
int indexOfSorted(ElementComparator &comparator, TargetValueType elementToLookFor) const
Definition juce_Array.h:730
ElementType getFirst() const noexcept
Definition juce_Array.h:290
ElementType * begin() noexcept
Definition juce_Array.h:328
ElementType * end() noexcept
Definition juce_Array.h:344
ElementType * getRawDataPointer() noexcept
Definition juce_Array.h:310
void swapWithArray(Array &other) noexcept
Definition juce_Array.h:1133
Array(ElementType &&singleElementToAdd)
Definition juce_Array.h:106
void addUsingDefaultSort(ParameterType newElement)
Definition juce_Array.h:711
int indexOf(ParameterType elementToLookFor) const
Definition juce_Array.h:382
void add(const std::pair< GridItem *, PlacementHelpers::LineArea > &newElement)
Definition juce_Array.h:418
Array(ElementType &&firstNewElement, OtherElements &&... otherElements)
Definition juce_Array.h:120
ElementType removeAndReturn(int indexToRemove)
Definition juce_Array.h:785
Array(const ElementType &singleElementToAdd)
Definition juce_Array.h:100
void set(int indexToChange, ParameterType newValue)
Definition juce_Array.h:542
int addSorted(ElementComparator &comparator, ParameterType newElement)
Definition juce_Array.h:694
bool contains(ParameterType elementToLookFor) const
Definition juce_Array.h:400
void insertMultiple(int indexToInsertAt, ParameterType newElement, int numberOfTimesToInsertIt)
Definition juce_Array.h:480
void sort(ElementComparator &comparator, bool retainOrderOfEquivalentItems=false)
Definition juce_Array.h:1109
void add(ElementType &&firstNewElement, OtherElements &&... otherElements)
Definition juce_Array.h:444
const ElementType * data() const noexcept
Definition juce_Array.h:368
void resize(int targetNumItems)
Definition juce_Array.h:670
void clear()
Definition juce_Array.h:188
void move(int currentIndex, int newIndex) noexcept
Definition juce_Array.h:1037
void swap(int index1, int index2)
Definition juce_Array.h:1017
std::pair< GridItem *, PlacementHelpers::LineArea > * data() noexcept
Definition juce_Array.h:360
void add(const ElementType &firstNewElement, OtherElements &&... otherElements)
Definition juce_Array.h:436
void removeValuesNotIn(const OtherArrayType &otherArray)
Definition juce_Array.h:989
std::enable_if<!std::is_pointer< OtherArrayType >::value, void >::type addArray(const OtherArrayType &arrayToAddFrom, int startIndex, int numElementsToAdd=-1)
Definition juce_Array.h:653
const ElementType * begin() const noexcept
Definition juce_Array.h:336
ArrayBase< std::pair< GridItem *, PlacementHelpers::LineArea >, DummyCriticalSection > values
Definition juce_Array.h:1138
const ElementType & getReference(int index) const noexcept
Definition juce_Array.h:281
bool addIfNotAlreadyThere(ParameterType newElement)
Definition juce_Array.h:522
void removeInternal(int indexToRemove)
Definition juce_Array.h:1140
Array(const Array &other)
Definition juce_Array.h:68
void minimiseStorageOverheads()
Definition juce_Array.h:1053
void addArray(const OtherArrayType &arrayToAddFrom)
Definition juce_Array.h:634
void minimiseStorageAfterRemoval()
Definition juce_Array.h:1146
ElementType & getReference(int index) noexcept
Definition juce_Array.h:267
ElementType getLast() const noexcept
Definition juce_Array.h:300
const ElementType * getRawDataPointer() const noexcept
Definition juce_Array.h:319
Definition juce_ElementComparator.h:188
* e
Definition inflate.c:1404
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
Definition carla_juce.cpp:31
static int findInsertIndexInSortedArray(ElementComparator &comparator, ElementType *const array, const ElementType newElement, int firstElement, int lastElement)
Definition juce_ElementComparator.h:126
constexpr Type jmax(Type a, Type b)
Definition juce_MathsFunctions.h:94
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Definition juce_MathsFunctions.h:262
static void sortArray(ElementComparator &comparator, ElementType *const array, int firstElement, int lastElement, const bool retainOrderOfEquivalentItems)
Definition juce_ElementComparator.h:81
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
typedef int(UZ_EXP MsgFn)()
#define const
Definition zconf.h:137