47template <
class ObjectClass,
48 class TypeOfCriticalSectionToUse = DummyCriticalSection>
69 : values (std::move (
other.values))
74 OwnedArray (
const std::initializer_list<ObjectClass*>& items)
84 values = std::move (
other.values);
89 template <
class OtherObjectClass,
class OtherCriticalSection>
91 : values (std::move (
other.values))
96 template <
class OtherObjectClass,
class OtherCriticalSection>
101 values = std::move (
other.values);
111 values.setAllocatedSize (0);
132 return values.
size();
152 return values.getValueWithDefault (index);
163 return values[index];
174 return values.getFirst();
185 return values.getLast();
194 return values.
begin();
203 return values.
begin();
211 return values.
begin();
257 for (;
e != values.
end(); ++
e)
259 return static_cast<int> (
e - values.
begin());
274 for (;
e != values.
end(); ++
e)
406 std::unique_ptr<ObjectClass>
toDelete;
465 template <
class OtherArrayType>
476 template <
typename OtherArrayType>
477 void addArray (
const std::initializer_list<OtherArrayType>& items)
480 values.addArray (items);
497 template <
class OtherArrayType>
533 template <
class ElementComparator>
538 ignoreUnused (comparator);
541 auto index = findInsertIndexInSortedArray (comparator, values.begin(),
newObject, 0, values.
size());
558 template <
typename ElementComparator>
563 ignoreUnused (comparator);
566 int s = 0,
e = values.
size();
600 std::unique_ptr<ObjectClass>
toDelete;
616 if ((values.size() << 1) < values.capacity())
640 if ((values.size() << 1) < values.capacity())
659 for (
int i = 0; i < values.size(); ++i)
685 auto endIndex = jlimit (0, values.size(), startIndex +
numberToRemove);
686 startIndex = jlimit (0, values.size(), startIndex);
701 if ((values.size() << 1) < values.capacity())
761 template <
class OtherArrayType>
779 values.shrinkToNoMoreThan (values.size());
820 template <
class ElementComparator>
826 ignoreUnused (comparator);
853 ArrayBase <ObjectClass*, TypeOfCriticalSectionToUse> values;
855 void deleteAllObjects()
857 auto i = values.size();
862 values.removeElements (i, 1);
867 template <
class OtherObjectClass,
class OtherCriticalSection>
870 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OwnedArray)
ElementType getUnchecked(int index) const
const TypeOfCriticalSectionToUse & getLock() const noexcept
void addArray(const Type *elementsToAdd, int numElementsToAdd)
int size() const noexcept
ElementType * begin() noexcept
ElementType * end() noexcept
void add(const ElementType &newElement)
ObjectClass *const * data() const noexcept
int size() const noexcept
ObjectClass * getUnchecked(int index) const noexcept
ObjectClass * set(int indexToChange, ObjectClass *newObject, bool deleteOldElement=true)
ObjectClass * removeAndReturn(int indexToRemove)
ObjectClass * add(std::unique_ptr< ObjectClass > newObject)
ObjectClass * set(int indexToChange, std::unique_ptr< ObjectClass > newObject, bool deleteOldElement=true)
void addCopiesOf(const OtherArrayType &arrayToAddFrom, int startIndex=0, int numElementsToAdd=-1)
void addArray(const OtherArrayType &arrayToAddFrom, int startIndex=0, int numElementsToAdd=-1)
bool isEmpty() const noexcept
void swapWith(OtherArrayType &otherArray) noexcept
void remove(int indexToRemove, bool deleteObject=true)
typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType
void ensureStorageAllocated(int minNumElements) noexcept
ObjectClass * getFirst() const noexcept
void minimiseStorageOverheads() noexcept
void clear(bool deleteObjects=true)
void removeLast(int howManyToRemove=1, bool deleteObjects=true)
int indexOf(const ObjectClass *objectToLookFor) const noexcept
ObjectClass * add(ObjectClass *newObject)
ObjectClass ** begin() noexcept
OwnedArray(OwnedArray< OtherObjectClass, OtherCriticalSection > &&other) noexcept
void swap(int index1, int index2) noexcept
int indexOfSorted(ElementComparator &comparator, const ObjectClass *objectToLookFor) const noexcept
ObjectClass * insert(int indexToInsertAt, std::unique_ptr< ObjectClass > newObject)
void clearQuick(bool deleteObjects)
void removeObject(const ObjectClass *objectToRemove, bool deleteObject=true)
ObjectClass *const * begin() const noexcept
ObjectClass *const * end() const noexcept
ObjectClass ** end() noexcept
OwnedArray & operator=(OwnedArray &&other) noexcept
OwnedArray(OwnedArray &&other) noexcept
void insertArray(int indexToInsertAt, ObjectClass *const *newObjects, int numberOfElements)
void move(int currentIndex, int newIndex) noexcept
int addSorted(ElementComparator &comparator, ObjectClass *newObject) noexcept
const TypeOfCriticalSectionToUse & getLock() const noexcept
void addArray(const std::initializer_list< OtherArrayType > &items)
void sort(ElementComparator &comparator, bool retainOrderOfEquivalentItems=false) noexcept
ObjectClass * insert(int indexToInsertAt, ObjectClass *newObject)
ObjectClass * operator[](int index) const noexcept
ObjectClass ** getRawDataPointer() noexcept
ObjectClass ** data() noexcept
OwnedArray(const std::initializer_list< ObjectClass * > &items)
void removeRange(int startIndex, int numberToRemove, bool deleteObjects=true)
ObjectClass * getLast() const noexcept
bool contains(const ObjectClass *objectToLookFor) const noexcept