openshot-audio  0.1.4
juce_Array.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the juce_core module of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission to use, copy, modify, and/or distribute this software for any purpose with
8  or without fee is hereby granted, provided that the above copyright notice and this
9  permission notice appear in all copies.
10 
11  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
12  TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
13  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
15  IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 
18  ------------------------------------------------------------------------------
19 
20  NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
21  All other JUCE modules are covered by a dual GPL/commercial license, so if you are
22  using any other modules, be sure to check that you also comply with their license.
23 
24  For more details, visit www.juce.com
25 
26  ==============================================================================
27 */
28 
29 #ifndef JUCE_ARRAY_H_INCLUDED
30 #define JUCE_ARRAY_H_INCLUDED
31 
32 
33 //==============================================================================
57 template <typename ElementType,
58  typename TypeOfCriticalSectionToUse = DummyCriticalSection,
59  int minimumAllocatedSize = 0>
60 class Array
61 {
62 private:
63  typedef PARAMETER_TYPE (ElementType) ParameterType;
64 
65 public:
66  //==============================================================================
69  {
70  }
71 
76  {
77  const ScopedLockType lock (other.getLock());
78  numUsed = other.numUsed;
79  data.setAllocatedSize (other.numUsed);
80 
81  for (int i = 0; i < numUsed; ++i)
82  new (data.elements + i) ElementType (other.data.elements[i]);
83  }
84 
85  #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
87  : data (static_cast<ArrayAllocationBase<ElementType, TypeOfCriticalSectionToUse>&&> (other.data)),
88  numUsed (other.numUsed)
89  {
90  other.numUsed = 0;
91  }
92  #endif
93 
98  template <typename TypeToCreateFrom>
99  explicit Array (const TypeToCreateFrom* values) : numUsed (0)
100  {
101  while (*values != TypeToCreateFrom())
102  add (*values++);
103  }
104 
110  template <typename TypeToCreateFrom>
111  Array (const TypeToCreateFrom* values, int numValues) : numUsed (numValues)
112  {
113  data.setAllocatedSize (numValues);
114 
115  for (int i = 0; i < numValues; ++i)
116  new (data.elements + i) ElementType (values[i]);
117  }
118 
119  #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS
120  template <typename TypeToCreateFrom>
121  Array (const std::initializer_list<TypeToCreateFrom>& items) : numUsed (0)
122  {
123  addArray (items);
124  }
125  #endif
126 
129  {
131  }
132 
136  Array& operator= (const Array& other)
137  {
138  if (this != &other)
139  {
141  swapWith (otherCopy);
142  }
143 
144  return *this;
145  }
146 
147  #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
148  Array& operator= (Array&& other) noexcept
149  {
150  const ScopedLockType lock (getLock());
152  data = static_cast<ArrayAllocationBase<ElementType, TypeOfCriticalSectionToUse>&&> (other.data);
153  numUsed = other.numUsed;
154  other.numUsed = 0;
155  return *this;
156  }
157  #endif
158 
159  //==============================================================================
165  template <class OtherArrayType>
166  bool operator== (const OtherArrayType& other) const
167  {
168  const ScopedLockType lock (getLock());
169  const typename OtherArrayType::ScopedLockType lock2 (other.getLock());
170 
171  if (numUsed != other.numUsed)
172  return false;
173 
174  for (int i = numUsed; --i >= 0;)
175  if (! (data.elements [i] == other.data.elements [i]))
176  return false;
177 
178  return true;
179  }
180 
186  template <class OtherArrayType>
187  bool operator!= (const OtherArrayType& other) const
188  {
189  return ! operator== (other);
190  }
191 
192  //==============================================================================
200  void clear()
201  {
202  const ScopedLockType lock (getLock());
204  data.setAllocatedSize (0);
205  numUsed = 0;
206  }
207 
211  void clearQuick()
212  {
213  const ScopedLockType lock (getLock());
215  numUsed = 0;
216  }
217 
218  //==============================================================================
221  inline int size() const noexcept
222  {
223  return numUsed;
224  }
225 
236  ElementType operator[] (const int index) const
237  {
238  const ScopedLockType lock (getLock());
239 
240  if (isPositiveAndBelow (index, numUsed))
241  {
242  jassert (data.elements != nullptr);
243  return data.elements [index];
244  }
245 
246  return ElementType();
247  }
248 
258  inline ElementType getUnchecked (const int index) const
259  {
260  const ScopedLockType lock (getLock());
261  jassert (isPositiveAndBelow (index, numUsed) && data.elements != nullptr);
262  return data.elements [index];
263  }
264 
274  inline ElementType& getReference (const int index) const noexcept
275  {
276  const ScopedLockType lock (getLock());
277  jassert (isPositiveAndBelow (index, numUsed) && data.elements != nullptr);
278  return data.elements [index];
279  }
280 
285  inline ElementType getFirst() const
286  {
287  const ScopedLockType lock (getLock());
288 
289  if (numUsed > 0)
290  {
291  jassert (data.elements != nullptr);
292  return data.elements[0];
293  }
294 
295  return ElementType();
296  }
297 
302  inline ElementType getLast() const
303  {
304  const ScopedLockType lock (getLock());
305 
306  if (numUsed > 0)
307  {
308  jassert (data.elements != nullptr);
309  return data.elements[numUsed - 1];
310  }
311 
312  return ElementType();
313  }
314 
319  inline ElementType* getRawDataPointer() noexcept
320  {
321  return data.elements;
322  }
323 
324  //==============================================================================
328  inline ElementType* begin() const noexcept
329  {
330  return data.elements;
331  }
332 
336  inline ElementType* end() const noexcept
337  {
338  #if JUCE_DEBUG
339  if (data.elements == nullptr || numUsed <= 0) // (to keep static analysers happy)
340  return data.elements;
341  #endif
342 
343  return data.elements + numUsed;
344  }
345 
346  //==============================================================================
355  int indexOf (ParameterType elementToLookFor) const
356  {
357  const ScopedLockType lock (getLock());
358  const ElementType* e = data.elements.getData();
359  const ElementType* const end_ = e + numUsed;
360 
361  for (; e != end_; ++e)
362  if (elementToLookFor == *e)
363  return static_cast <int> (e - data.elements.getData());
364 
365  return -1;
366  }
367 
373  bool contains (ParameterType elementToLookFor) const
374  {
375  const ScopedLockType lock (getLock());
376  const ElementType* e = data.elements.getData();
377  const ElementType* const end_ = e + numUsed;
378 
379  for (; e != end_; ++e)
380  if (elementToLookFor == *e)
381  return true;
382 
383  return false;
384  }
385 
386  //==============================================================================
392  void add (const ElementType& newElement)
393  {
394  const ScopedLockType lock (getLock());
395  data.ensureAllocatedSize (numUsed + 1);
396  new (data.elements + numUsed++) ElementType (newElement);
397  }
398 
399  #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
400 
405  void add (ElementType&& newElement)
406  {
407  const ScopedLockType lock (getLock());
408  data.ensureAllocatedSize (numUsed + 1);
409  new (data.elements + numUsed++) ElementType (static_cast<ElementType&&> (newElement));
410  }
411  #endif
412 
425  void insert (int indexToInsertAt, ParameterType newElement)
426  {
427  const ScopedLockType lock (getLock());
428  data.ensureAllocatedSize (numUsed + 1);
429  jassert (data.elements != nullptr);
430 
431  if (isPositiveAndBelow (indexToInsertAt, numUsed))
432  {
433  ElementType* const insertPos = data.elements + indexToInsertAt;
434  const int numberToMove = numUsed - indexToInsertAt;
435 
436  if (numberToMove > 0)
437  memmove (insertPos + 1, insertPos, ((size_t) numberToMove) * sizeof (ElementType));
438 
439  new (insertPos) ElementType (newElement);
440  ++numUsed;
441  }
442  else
443  {
444  new (data.elements + numUsed++) ElementType (newElement);
445  }
446  }
447 
460  void insertMultiple (int indexToInsertAt, ParameterType newElement,
461  int numberOfTimesToInsertIt)
462  {
463  if (numberOfTimesToInsertIt > 0)
464  {
465  const ScopedLockType lock (getLock());
466  data.ensureAllocatedSize (numUsed + numberOfTimesToInsertIt);
467  ElementType* insertPos;
468 
469  if (isPositiveAndBelow (indexToInsertAt, numUsed))
470  {
471  insertPos = data.elements + indexToInsertAt;
472  const int numberToMove = numUsed - indexToInsertAt;
473  memmove (insertPos + numberOfTimesToInsertIt, insertPos, ((size_t) numberToMove) * sizeof (ElementType));
474  }
475  else
476  {
477  insertPos = data.elements + numUsed;
478  }
479 
480  numUsed += numberOfTimesToInsertIt;
481 
482  while (--numberOfTimesToInsertIt >= 0)
483  {
484  new (insertPos) ElementType (newElement);
485  ++insertPos; // NB: this increment is done separately from the
486  // new statement to avoid a compiler bug in VS2014
487  }
488  }
489  }
490 
503  void insertArray (int indexToInsertAt,
504  const ElementType* newElements,
505  int numberOfElements)
506  {
507  if (numberOfElements > 0)
508  {
509  const ScopedLockType lock (getLock());
510  data.ensureAllocatedSize (numUsed + numberOfElements);
511  ElementType* insertPos = data.elements;
512 
513  if (isPositiveAndBelow (indexToInsertAt, numUsed))
514  {
515  insertPos += indexToInsertAt;
516  const int numberToMove = numUsed - indexToInsertAt;
517  memmove (insertPos + numberOfElements, insertPos, numberToMove * sizeof (ElementType));
518  }
519  else
520  {
521  insertPos += numUsed;
522  }
523 
524  numUsed += numberOfElements;
525 
526  while (--numberOfElements >= 0)
527  new (insertPos++) ElementType (*newElements++);
528  }
529  }
530 
539  void addIfNotAlreadyThere (ParameterType newElement)
540  {
541  const ScopedLockType lock (getLock());
542 
543  if (! contains (newElement))
544  add (newElement);
545  }
546 
556  void set (const int indexToChange, ParameterType newValue)
557  {
558  jassert (indexToChange >= 0);
559  const ScopedLockType lock (getLock());
560 
561  if (isPositiveAndBelow (indexToChange, numUsed))
562  {
563  jassert (data.elements != nullptr);
564  data.elements [indexToChange] = newValue;
565  }
566  else if (indexToChange >= 0)
567  {
568  data.ensureAllocatedSize (numUsed + 1);
569  new (data.elements + numUsed++) ElementType (newValue);
570  }
571  }
572 
582  void setUnchecked (const int indexToChange, ParameterType newValue)
583  {
584  const ScopedLockType lock (getLock());
585  jassert (isPositiveAndBelow (indexToChange, numUsed));
586  data.elements [indexToChange] = newValue;
587  }
588 
596  template <typename Type>
597  void addArray (const Type* elementsToAdd, int numElementsToAdd)
598  {
599  const ScopedLockType lock (getLock());
600 
601  if (numElementsToAdd > 0)
602  {
603  data.ensureAllocatedSize (numUsed + numElementsToAdd);
604 
605  while (--numElementsToAdd >= 0)
606  {
607  new (data.elements + numUsed) ElementType (*elementsToAdd++);
608  ++numUsed;
609  }
610  }
611  }
612 
613  #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS
614  template <typename TypeToCreateFrom>
615  void addArray (const std::initializer_list<TypeToCreateFrom>& items)
616  {
617  const ScopedLockType lock (getLock());
618  data.ensureAllocatedSize (numUsed + (int) items.size());
619 
620  for (auto& item : items)
621  {
622  new (data.elements + numUsed) ElementType (item);
623  ++numUsed;
624  }
625  }
626  #endif
627 
634  template <typename Type>
635  void addNullTerminatedArray (const Type* const* elementsToAdd)
636  {
637  int num = 0;
638  for (const Type* const* e = elementsToAdd; *e != nullptr; ++e)
639  ++num;
640 
641  addArray (elementsToAdd, num);
642  }
643 
649  template <class OtherArrayType>
650  void swapWith (OtherArrayType& otherArray) noexcept
651  {
652  const ScopedLockType lock1 (getLock());
653  const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
654  data.swapWith (otherArray.data);
655  std::swap (numUsed, otherArray.numUsed);
656  }
657 
667  template <class OtherArrayType>
668  void addArray (const OtherArrayType& arrayToAddFrom,
669  int startIndex = 0,
670  int numElementsToAdd = -1)
671  {
672  const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock());
673 
674  {
675  const ScopedLockType lock2 (getLock());
676 
677  if (startIndex < 0)
678  {
679  jassertfalse;
680  startIndex = 0;
681  }
682 
683  if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size())
684  numElementsToAdd = arrayToAddFrom.size() - startIndex;
685 
686  while (--numElementsToAdd >= 0)
687  add (arrayToAddFrom.getUnchecked (startIndex++));
688  }
689  }
690 
698  void resize (const int targetNumItems)
699  {
700  jassert (targetNumItems >= 0);
701 
702  const int numToAdd = targetNumItems - numUsed;
703  if (numToAdd > 0)
704  insertMultiple (numUsed, ElementType(), numToAdd);
705  else if (numToAdd < 0)
706  removeRange (targetNumItems, -numToAdd);
707  }
708 
721  template <class ElementComparator>
722  int addSorted (ElementComparator& comparator, ParameterType newElement)
723  {
724  const ScopedLockType lock (getLock());
725  const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newElement, 0, numUsed);
726  insert (index, newElement);
727  return index;
728  }
729 
739  void addUsingDefaultSort (ParameterType newElement)
740  {
742  addSorted (comparator, newElement);
743  }
744 
757  template <typename ElementComparator, typename TargetValueType>
758  int indexOfSorted (ElementComparator& comparator, TargetValueType elementToLookFor) const
759  {
760  (void) comparator; // if you pass in an object with a static compareElements() method, this
761  // avoids getting warning messages about the parameter being unused
762 
763  const ScopedLockType lock (getLock());
764 
765  for (int s = 0, e = numUsed;;)
766  {
767  if (s >= e)
768  return -1;
769 
770  if (comparator.compareElements (elementToLookFor, data.elements [s]) == 0)
771  return s;
772 
773  const int halfway = (s + e) / 2;
774  if (halfway == s)
775  return -1;
776 
777  if (comparator.compareElements (elementToLookFor, data.elements [halfway]) >= 0)
778  s = halfway;
779  else
780  e = halfway;
781  }
782  }
783 
784  //==============================================================================
795  ElementType remove (const int indexToRemove)
796  {
797  const ScopedLockType lock (getLock());
798 
799  if (isPositiveAndBelow (indexToRemove, numUsed))
800  {
801  jassert (data.elements != nullptr);
802  ElementType removed (data.elements[indexToRemove]);
803  removeInternal (indexToRemove);
804  return removed;
805  }
806 
807  return ElementType();
808  }
809 
818  void removeFirstMatchingValue (ParameterType valueToRemove)
819  {
820  const ScopedLockType lock (getLock());
821  ElementType* const e = data.elements;
822 
823  for (int i = 0; i < numUsed; ++i)
824  {
825  if (valueToRemove == e[i])
826  {
827  removeInternal (i);
828  break;
829  }
830  }
831  }
832 
841  void removeAllInstancesOf (ParameterType valueToRemove)
842  {
843  const ScopedLockType lock (getLock());
844 
845  for (int i = numUsed; --i >= 0;)
846  if (valueToRemove == data.elements[i])
847  removeInternal (i);
848  }
849 
862  void removeRange (int startIndex, int numberToRemove)
863  {
864  const ScopedLockType lock (getLock());
865  const int endIndex = jlimit (0, numUsed, startIndex + numberToRemove);
866  startIndex = jlimit (0, numUsed, startIndex);
867 
868  if (endIndex > startIndex)
869  {
870  ElementType* const e = data.elements + startIndex;
871 
872  numberToRemove = endIndex - startIndex;
873  for (int i = 0; i < numberToRemove; ++i)
874  e[i].~ElementType();
875 
876  const int numToShift = numUsed - endIndex;
877  if (numToShift > 0)
878  memmove (e, e + numberToRemove, ((size_t) numToShift) * sizeof (ElementType));
879 
880  numUsed -= numberToRemove;
882  }
883  }
884 
890  void removeLast (int howManyToRemove = 1)
891  {
892  const ScopedLockType lock (getLock());
893 
894  if (howManyToRemove > numUsed)
895  howManyToRemove = numUsed;
896 
897  for (int i = 1; i <= howManyToRemove; ++i)
898  data.elements [numUsed - i].~ElementType();
899 
900  numUsed -= howManyToRemove;
902  }
903 
909  template <class OtherArrayType>
910  void removeValuesIn (const OtherArrayType& otherArray)
911  {
912  const typename OtherArrayType::ScopedLockType lock1 (otherArray.getLock());
913  const ScopedLockType lock2 (getLock());
914 
915  if (this == &otherArray)
916  {
917  clear();
918  }
919  else
920  {
921  if (otherArray.size() > 0)
922  {
923  for (int i = numUsed; --i >= 0;)
924  if (otherArray.contains (data.elements [i]))
925  removeInternal (i);
926  }
927  }
928  }
929 
937  template <class OtherArrayType>
938  void removeValuesNotIn (const OtherArrayType& otherArray)
939  {
940  const typename OtherArrayType::ScopedLockType lock1 (otherArray.getLock());
941  const ScopedLockType lock2 (getLock());
942 
943  if (this != &otherArray)
944  {
945  if (otherArray.size() <= 0)
946  {
947  clear();
948  }
949  else
950  {
951  for (int i = numUsed; --i >= 0;)
952  if (! otherArray.contains (data.elements [i]))
953  removeInternal (i);
954  }
955  }
956  }
957 
966  void swap (const int index1,
967  const int index2)
968  {
969  const ScopedLockType lock (getLock());
970 
971  if (isPositiveAndBelow (index1, numUsed)
972  && isPositiveAndBelow (index2, numUsed))
973  {
974  std::swap (data.elements [index1],
975  data.elements [index2]);
976  }
977  }
978 
993  void move (const int currentIndex, int newIndex) noexcept
994  {
995  if (currentIndex != newIndex)
996  {
997  const ScopedLockType lock (getLock());
998 
999  if (isPositiveAndBelow (currentIndex, numUsed))
1000  {
1001  if (! isPositiveAndBelow (newIndex, numUsed))
1002  newIndex = numUsed - 1;
1003 
1004  char tempCopy [sizeof (ElementType)];
1005  memcpy (tempCopy, data.elements + currentIndex, sizeof (ElementType));
1006 
1007  if (newIndex > currentIndex)
1008  {
1009  memmove (data.elements + currentIndex,
1010  data.elements + currentIndex + 1,
1011  sizeof (ElementType) * (size_t) (newIndex - currentIndex));
1012  }
1013  else
1014  {
1015  memmove (data.elements + newIndex + 1,
1016  data.elements + newIndex,
1017  sizeof (ElementType) * (size_t) (currentIndex - newIndex));
1018  }
1019 
1020  memcpy (data.elements + newIndex, tempCopy, sizeof (ElementType));
1021  }
1022  }
1023  }
1024 
1025  //==============================================================================
1033  {
1034  const ScopedLockType lock (getLock());
1035  data.shrinkToNoMoreThan (numUsed);
1036  }
1037 
1044  void ensureStorageAllocated (const int minNumElements)
1045  {
1046  const ScopedLockType lock (getLock());
1047  data.ensureAllocatedSize (minNumElements);
1048  }
1049 
1050  //==============================================================================
1077  template <class ElementComparator>
1078  void sort (ElementComparator& comparator,
1079  const bool retainOrderOfEquivalentItems = false) const
1080  {
1081  const ScopedLockType lock (getLock());
1082  (void) comparator; // if you pass in an object with a static compareElements() method, this
1083  // avoids getting warning messages about the parameter being unused
1084  sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems);
1085  }
1086 
1087  //==============================================================================
1092  inline const TypeOfCriticalSectionToUse& getLock() const noexcept { return data; }
1093 
1095  typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType;
1096 
1097 
1098  //==============================================================================
1099  #ifndef DOXYGEN
1100  // Note that the swapWithArray method has been replaced by a more flexible templated version,
1101  // and renamed "swapWith" to be more consistent with the names used in other classes.
1102  JUCE_DEPRECATED_WITH_BODY (void swapWithArray (Array& other) noexcept, { swapWith (other); })
1103  #endif
1104 
1105 private:
1106  //==============================================================================
1108  int numUsed;
1109 
1110  void removeInternal (const int indexToRemove)
1111  {
1112  --numUsed;
1113  ElementType* const e = data.elements + indexToRemove;
1114  e->~ElementType();
1115  const int numberToShift = numUsed - indexToRemove;
1116 
1117  if (numberToShift > 0)
1118  memmove (e, e + 1, ((size_t) numberToShift) * sizeof (ElementType));
1119 
1121  }
1122 
1123  inline void deleteAllElements() noexcept
1124  {
1125  for (int i = 0; i < numUsed; ++i)
1126  data.elements[i].~ElementType();
1127  }
1128 
1130  {
1131  if (data.numAllocated > jmax (minimumAllocatedSize, numUsed * 2))
1132  data.shrinkToNoMoreThan (jmax (numUsed, jmax (minimumAllocatedSize, 64 / (int) sizeof (ElementType))));
1133  }
1134 };
1135 
1136 
1137 #endif // JUCE_ARRAY_H_INCLUDED
void removeLast(int howManyToRemove=1)
Definition: juce_Array.h:890
Array() noexcept
Definition: juce_Array.h:68
bool operator==(const OtherArrayType &other) const
Definition: juce_Array.h:166
void clearQuick()
Definition: juce_Array.h:211
void insertMultiple(int indexToInsertAt, ParameterType newElement, int numberOfTimesToInsertIt)
Definition: juce_Array.h:460
Array(const TypeToCreateFrom *values, int numValues)
Definition: juce_Array.h:111
JUCE_DEPRECATED_WITH_BODY(void swapWithArray(Array &other) noexcept, { swapWith(other);}) private int numUsed
Definition: juce_Array.h:1102
void removeAllInstancesOf(ParameterType valueToRemove)
Definition: juce_Array.h:841
const TypeOfCriticalSectionToUse & getLock() const noexcept
Definition: juce_Array.h:1092
#define noexcept
Definition: juce_CompilerSupport.h:141
void insertArray(int indexToInsertAt, const ElementType *newElements, int numberOfElements)
Definition: juce_Array.h:503
bool isPositiveAndBelow(Type valueToTest, Type upperLimit) noexcept
Definition: juce_core.h:238
Definition: juce_ArrayAllocationBase.h:46
bool contains(ParameterType elementToLookFor) const
Definition: juce_Array.h:373
void add(const ElementType &newElement)
Definition: juce_Array.h:392
#define jassertfalse
Definition: juce_PlatformDefs.h:141
void removeValuesNotIn(const OtherArrayType &otherArray)
Definition: juce_Array.h:938
void addIfNotAlreadyThere(ParameterType newElement)
Definition: juce_Array.h:539
void resize(const int targetNumItems)
Definition: juce_Array.h:698
void deleteAllElements() noexcept
Definition: juce_Array.h:1123
ElementType * end() const noexcept
Definition: juce_Array.h:336
ElementType operator[](const int index) const
Definition: juce_Array.h:236
ElementType & getReference(const int index) const noexcept
Definition: juce_Array.h:274
void removeRange(int startIndex, int numberToRemove)
Definition: juce_Array.h:862
void addUsingDefaultSort(ParameterType newElement)
Definition: juce_Array.h:739
bool operator!=(const OtherArrayType &other) const
Definition: juce_Array.h:187
void swapWith(OtherArrayType &otherArray) noexcept
Definition: juce_Array.h:650
void removeInternal(const int indexToRemove)
Definition: juce_Array.h:1110
int addSorted(ElementComparator &comparator, ParameterType newElement)
Definition: juce_Array.h:722
ElementType * begin() const noexcept
Definition: juce_Array.h:328
int indexOf(ParameterType elementToLookFor) const
Definition: juce_Array.h:355
void setUnchecked(const int indexToChange, ParameterType newValue)
Definition: juce_Array.h:582
Array(const TypeToCreateFrom *values)
Definition: juce_Array.h:99
void addArray(const OtherArrayType &arrayToAddFrom, int startIndex=0, int numElementsToAdd=-1)
Definition: juce_Array.h:668
void removeFirstMatchingValue(ParameterType valueToRemove)
Definition: juce_Array.h:818
void addArray(const Type *elementsToAdd, int numElementsToAdd)
Definition: juce_Array.h:597
Type jmax(const Type a, const Type b)
Definition: juce_core.h:101
~Array()
Definition: juce_Array.h:128
int indexOfSorted(ElementComparator &comparator, TargetValueType elementToLookFor) const
Definition: juce_Array.h:758
void removeValuesIn(const OtherArrayType &otherArray)
Definition: juce_Array.h:910
ElementType getLast() const
Definition: juce_Array.h:302
Type jlimit(const Type lowerLimit, const Type upperLimit, const Type valueToConstrain) noexcept
Definition: juce_MathsFunctions.h:220
Definition: juce_Array.h:60
#define jassert(a)
Definition: juce_PlatformDefs.h:146
Array & operator=(const Array &other)
Definition: juce_Array.h:136
ElementType getUnchecked(const int index) const
Definition: juce_Array.h:258
ElementType getFirst() const
Definition: juce_Array.h:285
void move(const int currentIndex, int newIndex) noexcept
Definition: juce_Array.h:993
void minimiseStorageOverheads()
Definition: juce_Array.h:1032
void sort(ElementComparator &comparator, const bool retainOrderOfEquivalentItems=false) const
Definition: juce_Array.h:1078
void clear()
Definition: juce_Array.h:200
void ensureStorageAllocated(const int minNumElements)
Definition: juce_Array.h:1044
Definition: juce_CriticalSection.h:136
ElementType * getRawDataPointer() noexcept
Definition: juce_Array.h:319
void insert(int indexToInsertAt, ParameterType newElement)
Definition: juce_Array.h:425
Array(const Array< ElementType, TypeOfCriticalSectionToUse > &other)
Definition: juce_Array.h:75
void addNullTerminatedArray(const Type *const *elementsToAdd)
Definition: juce_Array.h:635
DummyCriticalSection ::ScopedLockType ScopedLockType
Definition: juce_Array.h:1095
#define JUCE_DEPRECATED_WITH_BODY(functionDef, body)
Definition: juce_PlatformDefs.h:320
Definition: juce_ElementComparator.h:182
void minimiseStorageAfterRemoval()
Definition: juce_Array.h:1129
int size() const noexcept
Definition: juce_Array.h:221
void swap(const int index1, const int index2)
Definition: juce_Array.h:966