JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_Array.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
52template <typename ElementType,
53 typename TypeOfCriticalSectionToUse = DummyCriticalSection,
55class Array
56{
57private:
58 using ParameterType = typename TypeHelpers::ParameterType<ElementType>::type;
59
60public:
61 //==============================================================================
63 Array() = default;
64
68 Array (const Array& other)
69 {
70 const ScopedLockType lock (other.getLock());
71 values.addArray (other.values.begin(), other.values.size());
72 }
73
74 Array (Array&& other) noexcept
75 : values (std::move (other.values))
76 {
77 }
78
82 template <typename TypeToCreateFrom>
83 explicit Array (const TypeToCreateFrom* data)
84 {
85 while (*values != TypeToCreateFrom())
86 add (*data++);
87 }
88
93 template <typename TypeToCreateFrom>
95 {
96 values.addArray (data, numValues);
97 }
98
100 Array (const ElementType& singleElementToAdd)
101 {
103 }
104
106 Array (ElementType&& singleElementToAdd)
107 {
108 add (std::move (singleElementToAdd));
109 }
110
112 template <typename... OtherElements>
114 {
115 values.add (firstNewElement, std::forward<OtherElements> (otherElements)...);
116 }
117
119 template <typename... OtherElements>
121 {
122 values.add (std::move (firstNewElement), std::forward<OtherElements> (otherElements)...);
123 }
124
125 template <typename TypeToCreateFrom>
127 {
128 addArray (items);
129 }
130
132 ~Array() = default;
133
138 {
139 if (this != &other)
140 {
141 auto otherCopy (other);
143 }
144
145 return *this;
146 }
147
148 Array& operator= (Array&& other) noexcept
149 {
150 const ScopedLockType lock (getLock());
151 values = std::move (other.values);
152 return *this;
153 }
154
155 //==============================================================================
161 template <class OtherArrayType>
163 {
164 const ScopedLockType lock (getLock());
165 const typename OtherArrayType::ScopedLockType lock2 (other.getLock());
166 return values == other;
167 }
168
174 template <class OtherArrayType>
176 {
177 return ! operator== (other);
178 }
179
180 //==============================================================================
188 void clear()
189 {
190 const ScopedLockType lock (getLock());
191 clearQuick();
192 values.setAllocatedSize (0);
193 }
194
199 {
200 const ScopedLockType lock (getLock());
201 values.clear();
202 }
203
205 void fill (const ParameterType& newValue) noexcept
206 {
207 const ScopedLockType lock (getLock());
208
209 for (auto& e : *this)
210 e = newValue;
211 }
212
213 //==============================================================================
215 inline int size() const noexcept
216 {
217 const ScopedLockType lock (getLock());
218 return values.size();
219 }
220
222 inline bool isEmpty() const noexcept
223 {
224 return size() == 0;
225 }
226
237 ElementType operator[] (int index) const
238 {
239 const ScopedLockType lock (getLock());
240 return values.getValueWithDefault (index);
241 }
242
252 inline ElementType getUnchecked (int index) const
253 {
254 const ScopedLockType lock (getLock());
255 return values[index];
256 }
257
267 inline ElementType& getReference (int index) noexcept
268 {
269 const ScopedLockType lock (getLock());
270 return values[index];
271 }
272
281 inline const ElementType& getReference (int index) const noexcept
282 {
283 const ScopedLockType lock (getLock());
284 return values[index];
285 }
286
290 inline ElementType getFirst() const noexcept
291 {
292 const ScopedLockType lock (getLock());
293 return values.getFirst();
294 }
295
300 inline ElementType getLast() const noexcept
301 {
302 const ScopedLockType lock (getLock());
303 return values.getLast();
304 }
305
310 inline ElementType* getRawDataPointer() noexcept
311 {
312 return values.begin();
313 }
314
319 inline const ElementType* getRawDataPointer() const noexcept
320 {
321 return values.begin();
322 }
323
324 //==============================================================================
328 inline ElementType* begin() noexcept
329 {
330 return values.begin();
331 }
332
336 inline const ElementType* begin() const noexcept
337 {
338 return values.begin();
339 }
340
344 inline ElementType* end() noexcept
345 {
346 return values.end();
347 }
348
352 inline const ElementType* end() const noexcept
353 {
354 return values.end();
355 }
356
360 inline ElementType* data() noexcept
361 {
362 return begin();
363 }
364
368 inline const ElementType* data() const noexcept
369 {
370 return begin();
371 }
372
373 //==============================================================================
382 int indexOf (ParameterType elementToLookFor) const
383 {
384 const ScopedLockType lock (getLock());
385 auto e = values.begin();
386 auto endPtr = values.end();
387
388 for (; e != endPtr; ++e)
390 return static_cast<int> (e - values.begin());
391
392 return -1;
393 }
394
400 bool contains (ParameterType elementToLookFor) const
401 {
402 const ScopedLockType lock (getLock());
403 auto e = values.begin();
404 auto endPtr = values.end();
405
406 for (; e != endPtr; ++e)
408 return true;
409
410 return false;
411 }
412
413 //==============================================================================
418 void add (const ElementType& newElement)
419 {
420 const ScopedLockType lock (getLock());
421 values.add (newElement);
422 }
423
428 void add (ElementType&& newElement)
429 {
430 const ScopedLockType lock (getLock());
431 values.add (std::move (newElement));
432 }
433
435 template <typename... OtherElements>
436 void add (const ElementType& firstNewElement, OtherElements&&... otherElements)
437 {
438 const ScopedLockType lock (getLock());
439 values.add (firstNewElement, std::forward<OtherElements> (otherElements)...);
440 }
441
443 template <typename... OtherElements>
445 {
446 const ScopedLockType lock (getLock());
447 values.add (std::move (firstNewElement), std::forward<OtherElements> (otherElements)...);
448 }
449
462 void insert (int indexToInsertAt, ParameterType newElement)
463 {
464 const ScopedLockType lock (getLock());
465 values.insert (indexToInsertAt, newElement, 1);
466 }
467
480 void insertMultiple (int indexToInsertAt, ParameterType newElement,
482 {
484 {
485 const ScopedLockType lock (getLock());
487 }
488 }
489
503 const ElementType* newElements,
505 {
506 if (numberOfElements > 0)
507 {
508 const ScopedLockType lock (getLock());
509 values.insertArray (indexToInsertAt, newElements, numberOfElements);
510 }
511 }
512
522 bool addIfNotAlreadyThere (ParameterType newElement)
523 {
524 const ScopedLockType lock (getLock());
525
526 if (contains (newElement))
527 return false;
528
529 add (newElement);
530 return true;
531 }
532
542 void set (int indexToChange, ParameterType newValue)
543 {
544 if (indexToChange >= 0)
545 {
546 const ScopedLockType lock (getLock());
547
548 if (indexToChange < values.size())
549 values[indexToChange] = newValue;
550 else
551 values.add (newValue);
552 }
553 else
554 {
556 }
557 }
558
568 void setUnchecked (int indexToChange, ParameterType newValue)
569 {
570 const ScopedLockType lock (getLock());
571 jassert (isPositiveAndBelow (indexToChange, values.size()));
572 values[indexToChange] = newValue;
573 }
574
582 template <typename Type>
584 {
585 const ScopedLockType lock (getLock());
586
587 if (numElementsToAdd > 0)
588 values.addArray (elementsToAdd, numElementsToAdd);
589 }
590
591 template <typename TypeToCreateFrom>
593 {
594 const ScopedLockType lock (getLock());
595 values.addArray (items);
596 }
597
604 template <typename Type>
605 void addNullTerminatedArray (const Type* const* elementsToAdd)
606 {
607 int num = 0;
608
609 for (auto e = elementsToAdd; *e != nullptr; ++e)
610 ++num;
611
612 addArray (elementsToAdd, num);
613 }
614
620 template <class OtherArrayType>
622 {
623 const ScopedLockType lock1 (getLock());
624 const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
625 values.swapWith (otherArray.values);
626 }
627
633 template <class OtherArrayType>
635 {
636 const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock());
637 const ScopedLockType lock2 (getLock());
638
639 values.addArray (arrayToAddFrom);
640 }
641
651 template <class OtherArrayType>
654 int startIndex,
655 int numElementsToAdd = -1)
656 {
657 const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock());
658 const ScopedLockType lock2 (getLock());
659
660 values.addArray (arrayToAddFrom, startIndex, numElementsToAdd);
661 }
662
671 {
672 jassert (targetNumItems >= 0);
673 auto numToAdd = targetNumItems - values.size();
674
675 if (numToAdd > 0)
676 insertMultiple (values.size(), ElementType(), numToAdd);
677 else if (numToAdd < 0)
679 }
680
693 template <class ElementComparator>
694 int addSorted (ElementComparator& comparator, ParameterType newElement)
695 {
696 const ScopedLockType lock (getLock());
697 auto index = findInsertIndexInSortedArray (comparator, values.begin(), newElement, 0, values.size());
698 insert (index, newElement);
699 return index;
700 }
701
711 void addUsingDefaultSort (ParameterType newElement)
712 {
714 addSorted (comparator, newElement);
715 }
716
729 template <typename ElementComparator, typename TargetValueType>
731
732 //==============================================================================
743 {
744 const ScopedLockType lock (getLock());
745
746 if (isPositiveAndBelow (indexToRemove, values.size()))
747 removeInternal (indexToRemove);
748 }
749
761 {
762 const ScopedLockType lock (getLock());
763
764 if (isPositiveAndBelow (indexToRemove, values.size()))
765 {
766 ElementType removed (values[indexToRemove]);
767 removeInternal (indexToRemove);
768 return removed;
769 }
770
771 return ElementType();
772 }
773
784 void remove (const ElementType* elementToRemove)
785 {
786 jassert (elementToRemove != nullptr);
787 const ScopedLockType lock (getLock());
788
789 jassert (values.begin() != nullptr);
790 auto indexToRemove = (int) (elementToRemove - values.begin());
791
792 if (! isPositiveAndBelow (indexToRemove, values.size()))
793 {
795 return;
796 }
797
798 removeInternal (indexToRemove);
799 }
800
811 {
812 const ScopedLockType lock (getLock());
813 auto* e = values.begin();
814
815 for (int i = 0; i < values.size(); ++i)
816 {
817 if (valueToRemove == e[i])
818 {
819 removeInternal (i);
820 return i;
821 }
822 }
823
824 return -1;
825 }
826
837 {
838 int numRemoved = 0;
839 const ScopedLockType lock (getLock());
840
841 for (int i = values.size(); --i >= 0;)
842 {
843 if (valueToRemove == values[i])
844 {
845 removeInternal (i);
846 ++numRemoved;
847 }
848 }
849
850 return numRemoved;
851 }
852
864 template <typename PredicateType>
866 {
867 int numRemoved = 0;
868 const ScopedLockType lock (getLock());
869
870 for (int i = values.size(); --i >= 0;)
871 {
872 if (predicate (values[i]))
873 {
874 removeInternal (i);
875 ++numRemoved;
876 }
877 }
878
879 return numRemoved;
880 }
881
894 void removeRange (int startIndex, int numberToRemove)
895 {
896 const ScopedLockType lock (getLock());
897
898 auto endIndex = jlimit (0, values.size(), startIndex + numberToRemove);
899 startIndex = jlimit (0, values.size(), startIndex);
900 numberToRemove = endIndex - startIndex;
901
902 if (numberToRemove > 0)
903 {
904 values.removeElements (startIndex, numberToRemove);
905 minimiseStorageAfterRemoval();
906 }
907 }
908
915 {
917
918 if (howManyToRemove > 0)
919 {
920 const ScopedLockType lock (getLock());
921
922 if (howManyToRemove > values.size())
923 howManyToRemove = values.size();
924
925 values.removeElements (values.size() - howManyToRemove, howManyToRemove);
926 minimiseStorageAfterRemoval();
927 }
928 }
929
935 template <class OtherArrayType>
937 {
938 const typename OtherArrayType::ScopedLockType lock1 (otherArray.getLock());
939 const ScopedLockType lock2 (getLock());
940
941 if (this == &otherArray)
942 {
943 clear();
944 }
945 else
946 {
947 if (otherArray.size() > 0)
948 {
949 for (int i = values.size(); --i >= 0;)
950 if (otherArray.contains (values[i]))
951 removeInternal (i);
952 }
953 }
954 }
955
963 template <class OtherArrayType>
965 {
966 const typename OtherArrayType::ScopedLockType lock1 (otherArray.getLock());
967 const ScopedLockType lock2 (getLock());
968
969 if (this != &otherArray)
970 {
971 if (otherArray.size() <= 0)
972 {
973 clear();
974 }
975 else
976 {
977 for (int i = values.size(); --i >= 0;)
978 if (! otherArray.contains (values[i]))
979 removeInternal (i);
980 }
981 }
982 }
983
992 void swap (int index1, int index2)
993 {
994 const ScopedLockType lock (getLock());
995 values.swap (index1, index2);
996 }
997
1012 void move (int currentIndex, int newIndex) noexcept
1013 {
1014 if (currentIndex != newIndex)
1015 {
1016 const ScopedLockType lock (getLock());
1017 values.move (currentIndex, newIndex);
1018 }
1019 }
1020
1021 //==============================================================================
1029 {
1030 const ScopedLockType lock (getLock());
1031 values.shrinkToNoMoreThan (values.size());
1032 }
1033
1041 {
1042 const ScopedLockType lock (getLock());
1043 values.ensureAllocatedSize (minNumElements);
1044 }
1045
1046 //==============================================================================
1051 void sort()
1052 {
1054 sort (comparator);
1055 }
1056
1083 template <class ElementComparator>
1084 void sort (ElementComparator& comparator, bool retainOrderOfEquivalentItems = false);
1085
1086 //==============================================================================
1091 inline const TypeOfCriticalSectionToUse& getLock() const noexcept { return values; }
1092
1094 using ScopedLockType = typename TypeOfCriticalSectionToUse::ScopedLockType;
1095
1096
1097 //==============================================================================
1098 #ifndef DOXYGEN
1099 [[deprecated ("This method has been replaced by a more flexible templated version and renamed "
1100 "to swapWith to be more consistent with the names used in other classes.")]]
1101 void swapWithArray (Array& other) noexcept { swapWith (other); }
1102 #endif
1103
1104private:
1105 //==============================================================================
1107
1108 void removeInternal (int indexToRemove)
1109 {
1110 values.removeElements (indexToRemove, 1);
1111 minimiseStorageAfterRemoval();
1112 }
1113
1114 void minimiseStorageAfterRemoval()
1115 {
1116 if (values.capacity() > jmax (minimumAllocatedSize, values.size() * 2))
1117 values.shrinkToNoMoreThan (jmax (values.size(), jmax (minimumAllocatedSize, 64 / (int) sizeof (ElementType))));
1118 }
1119};
1120
1121//==============================================================================
1122template <typename ElementType, typename TypeOfCriticalSectionToUse, int minimumAllocatedSize>
1123template <typename ElementComparator, typename TargetValueType>
1125 [[maybe_unused]] ElementComparator& comparator,
1127{
1128 const ScopedLockType lock (getLock());
1129
1130 for (int s = 0, e = values.size();;)
1131 {
1132 if (s >= e)
1133 return -1;
1134
1135 if (comparator.compareElements (elementToLookFor, values[s]) == 0)
1136 return s;
1137
1138 auto halfway = (s + e) / 2;
1139
1140 if (halfway == s)
1141 return -1;
1142
1143 if (comparator.compareElements (elementToLookFor, values[halfway]) >= 0)
1144 s = halfway;
1145 else
1146 e = halfway;
1147 }
1148}
1149
1150template <typename ElementType, typename TypeOfCriticalSectionToUse, int minimumAllocatedSize>
1151template <class ElementComparator>
1153 [[maybe_unused]] ElementComparator& comparator,
1155{
1156 const ScopedLockType lock (getLock());
1157 sortArray (comparator, values.begin(), 0, size() - 1, retainOrderOfEquivalentItems);
1158}
1159
1160} // namespace juce
A basic object container.
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
int removeIf(PredicateType &&predicate)
Removes items from the array.
Definition juce_Array.h:865
bool operator==(const OtherArrayType &other) const
Compares this array to another one.
Definition juce_Array.h:162
void swapWith(OtherArrayType &otherArray) noexcept
This swaps the contents of this array with those of another array.
Definition juce_Array.h:621
void add(ElementType &&newElement)
Appends a new element at the end of the array.
Definition juce_Array.h:428
void setUnchecked(int indexToChange, ParameterType newValue)
Replaces an element with a new value without doing any bounds-checking.
Definition juce_Array.h:568
bool operator!=(const OtherArrayType &other) const
Compares this array to another one.
Definition juce_Array.h:175
typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType
Returns the type of scoped lock to use for locking this array.
void addNullTerminatedArray(const Type *const *elementsToAdd)
Adds elements from a null-terminated array of pointers to the end of this array.
Definition juce_Array.h:605
ElementType getUnchecked(int index) const
Returns one of the elements in the array, without checking the index passed in.
Definition juce_Array.h:252
void insertArray(int indexToInsertAt, const ElementType *newElements, int numberOfElements)
Inserts an array of values into this array at a given position.
Definition juce_Array.h:502
bool isEmpty() const noexcept
Returns true if the array is empty, false otherwise.
Definition juce_Array.h:222
void removeLast(int howManyToRemove=1)
Removes the last n elements from the array.
Definition juce_Array.h:914
Array(const ElementType &firstNewElement, OtherElements &&... otherElements)
Initialises an Array from a list of items.
Definition juce_Array.h:113
void ensureStorageAllocated(int minNumElements)
Increases the array's internal storage to hold a minimum number of elements.
std::enable_if_t<! std::is_pointer_v< OtherArrayType >, void > addArray(const OtherArrayType &arrayToAddFrom, int startIndex, int numElementsToAdd=-1)
Adds elements from another array to the end of this array.
Definition juce_Array.h:653
void remove(const ElementType *elementToRemove)
Removes an element from the array.
Definition juce_Array.h:784
const TypeOfCriticalSectionToUse & getLock() const noexcept
Returns the CriticalSection that locks this array.
void addArray(const Type *elementsToAdd, int numElementsToAdd)
Adds elements from an array to the end of this array.
Definition juce_Array.h:583
Array(const TypeToCreateFrom *data)
Initialises from a null-terminated raw array of values.
Definition juce_Array.h:83
void clearQuick()
Removes all elements from the array without freeing the array's allocated storage.
Definition juce_Array.h:198
void sort()
Sorts the array using a default comparison operation.
int removeAllInstancesOf(ParameterType valueToRemove)
Removes items from the array.
Definition juce_Array.h:836
Array(const TypeToCreateFrom *data, int numValues)
Initialises from a raw array of values.
Definition juce_Array.h:94
int size() const noexcept
Returns the current number of elements in the array.
Definition juce_Array.h:215
int removeFirstMatchingValue(ParameterType valueToRemove)
Removes an item from the array.
Definition juce_Array.h:810
void fill(const ParameterType &newValue) noexcept
Fills the Array with the provided value.
Definition juce_Array.h:205
void removeRange(int startIndex, int numberToRemove)
Removes a range of elements from the array.
Definition juce_Array.h:894
void removeValuesIn(const OtherArrayType &otherArray)
Removes any elements which are also in another array.
Definition juce_Array.h:936
const ElementType * end() const noexcept
Returns a pointer to the element which follows the last element in the array.
Definition juce_Array.h:352
void remove(int indexToRemove)
Removes an element from the array.
Definition juce_Array.h:742
void insert(int indexToInsertAt, ParameterType newElement)
Inserts a new element into the array at a given position.
Definition juce_Array.h:462
int indexOfSorted(ElementComparator &comparator, TargetValueType elementToLookFor) const
Finds the index of an element in the array, assuming that the array is sorted.
ElementType getFirst() const noexcept
Returns the first element in the array, or a default value if the array is empty.
Definition juce_Array.h:290
ElementType * begin() noexcept
Returns a pointer to the first element in the array.
Definition juce_Array.h:328
ElementType * end() noexcept
Returns a pointer to the element which follows the last element in the array.
Definition juce_Array.h:344
ElementType * getRawDataPointer() noexcept
Returns a pointer to the actual array data.
Definition juce_Array.h:310
Array(ElementType &&singleElementToAdd)
Initialises an Array of size 1 containing a single element.
Definition juce_Array.h:106
void addUsingDefaultSort(ParameterType newElement)
Inserts a new element into the array, assuming that the array is sorted.
Definition juce_Array.h:711
Array()=default
Creates an empty array.
int indexOf(ParameterType elementToLookFor) const
Finds the index of the first element which matches the value passed in.
Definition juce_Array.h:382
void add(const ElementType &newElement)
Appends a new element at the end of the array.
Definition juce_Array.h:418
Array(ElementType &&firstNewElement, OtherElements &&... otherElements)
Initialises an Array from a list of items.
Definition juce_Array.h:120
ElementType removeAndReturn(int indexToRemove)
Removes an element from the array.
Definition juce_Array.h:760
ElementType operator[](int index) const
Returns one of the elements in the array.
Definition juce_Array.h:237
Array(const ElementType &singleElementToAdd)
Initialises an Array of size 1 containing a single element.
Definition juce_Array.h:100
void set(int indexToChange, ParameterType newValue)
Replaces an element with a new value.
Definition juce_Array.h:542
int addSorted(ElementComparator &comparator, ParameterType newElement)
Inserts a new element into the array, assuming that the array is sorted.
Definition juce_Array.h:694
bool contains(ParameterType elementToLookFor) const
Returns true if the array contains at least one occurrence of an object.
Definition juce_Array.h:400
void insertMultiple(int indexToInsertAt, ParameterType newElement, int numberOfTimesToInsertIt)
Inserts multiple copies of an element into the array at a given position.
Definition juce_Array.h:480
void sort(ElementComparator &comparator, bool retainOrderOfEquivalentItems=false)
Sorts the elements in the array.
~Array()=default
Destructor.
void add(ElementType &&firstNewElement, OtherElements &&... otherElements)
Appends multiple new elements at the end of the array.
Definition juce_Array.h:444
const ElementType * data() const noexcept
Returns a pointer to the first element in the array.
Definition juce_Array.h:368
void resize(int targetNumItems)
This will enlarge or shrink the array to the given number of elements, by adding or removing items fr...
Definition juce_Array.h:670
void clear()
Removes all elements from the array.
Definition juce_Array.h:188
void move(int currentIndex, int newIndex) noexcept
Moves one of the values to a different position.
void swap(int index1, int index2)
Swaps over two elements in the array.
Definition juce_Array.h:992
ElementType * data() noexcept
Returns a pointer to the first element in the array.
Definition juce_Array.h:360
void add(const ElementType &firstNewElement, OtherElements &&... otherElements)
Appends multiple new elements at the end of the array.
Definition juce_Array.h:436
void removeValuesNotIn(const OtherArrayType &otherArray)
Removes any elements which are not found in another array.
Definition juce_Array.h:964
const ElementType * begin() const noexcept
Returns a pointer to the first element in the array.
Definition juce_Array.h:336
const ElementType & getReference(int index) const noexcept
Returns a direct reference to one of the elements in the array, without checking the index passed in.
Definition juce_Array.h:281
bool addIfNotAlreadyThere(ParameterType newElement)
Appends a new element at the end of the array as long as the array doesn't already contain it.
Definition juce_Array.h:522
Array(const Array &other)
Creates a copy of another array.
Definition juce_Array.h:68
void minimiseStorageOverheads()
Reduces the amount of storage being used by the array.
void addArray(const OtherArrayType &arrayToAddFrom)
Adds elements from another array to the end of this array.
Definition juce_Array.h:634
Array & operator=(const Array &other)
Copies another array.
Definition juce_Array.h:137
ElementType & getReference(int index) noexcept
Returns a direct reference to one of the elements in the array, without checking the index passed in.
Definition juce_Array.h:267
ElementType getLast() const noexcept
Returns the last element in the array, or a default value if the array is empty.
Definition juce_Array.h:300
const ElementType * getRawDataPointer() const noexcept
Returns a pointer to the actual array data.
Definition juce_Array.h:319
A simple ElementComparator class that can be used to sort an array of objects that support the '<' op...
#define jassert(expression)
Platform-independent assertion macro.
#define jassertfalse
This will always cause an assertion failure.
typedef int
JUCE Namespace.
constexpr bool exactlyEqual(Type a, Type b)
Equivalent to operator==, but suppresses float-equality warnings.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.