49template <
class ObjectClass,
class TypeOfCriticalSectionToUse = DummyCriticalSection>
69 o->incReferenceCount();
74 : values (std::move (
other.values))
79 template <
class OtherObjectClass,
class OtherCriticalSection>
87 o->incReferenceCount();
104 template <
class OtherObjectClass>
116 values = std::move (
other.values);
136 values.setAllocatedSize (0);
152 return values.
size();
196 return values.getValueWithDefault (index);
205 return values[index];
216 return values.getFirst();
227 return values.getLast();
236 return values.
begin();
245 return values.
begin();
253 return values.
begin();
303 return static_cast<int> (
e - values.
begin());
508 auto**
e = values.
end();
511 (*(--
e))->incReferenceCount();
527 template <
class ElementComparator>
531 auto index = findInsertIndexInSortedArray (comparator, values.begin(),
newObject, 0, values.
size());
541 template <
class ElementComparator>
545 auto index = findInsertIndexInSortedArray (comparator, values.begin(),
newObject, 0, values.
size());
547 if (index > 0 && comparator.compareElements (
newObject, values[index - 1]) == 0)
565 template <
class ElementComparator>
569 ignoreUnused (comparator);
571 int s = 0,
e = values.
size();
616 if ((values.size() << 1) < values.capacity())
642 if ((values.size() << 1) < values.capacity())
692 startIndex = jlimit (0, values.size(), startIndex);
693 auto endIndex = jlimit (0, values.size(), startIndex +
numberToRemove);
706 if ((values.size() << 1) < values.capacity())
727 remove (values.size() - 1);
739 if (isPositiveAndBelow (
index1, values.
size())
740 && isPositiveAndBelow (
index2, values.
size()))
774 template <
class OtherArrayType>
791 return values ==
other.values;
830 template <
class ElementComparator>
836 ignoreUnused (comparator);
852 values.shrinkToNoMoreThan (values.size());
886 ArrayBase<ObjectClass*, TypeOfCriticalSectionToUse> values;
888 void releaseAllObjects()
890 auto i = values.size();
895 values.removeElements (i, 1);
900 static void releaseObject (ObjectClass* o)
902 if (o !=
nullptr && o->decReferenceCountWithoutDeleting())
903 ContainerDeletePolicy<ObjectClass>::destroy (o);
const TypeOfCriticalSectionToUse & getLock() const noexcept
void addArray(const Type *elementsToAdd, int numElementsToAdd)
int size() const noexcept
ElementType * begin() noexcept
ElementType * end() noexcept
ReferenceCountedArray(ReferenceCountedArray &&other) noexcept
ObjectClass * add(const ObjectClassPtr &newObject)
bool isEmpty() const noexcept
int indexOf(const ObjectClass *objectToLookFor) const noexcept
ReferenceCountedArray(const ReferenceCountedArray &other) noexcept
int size() const noexcept
void removeLast(int howManyToRemove=1)
ObjectClass *const * end() const noexcept
void minimiseStorageOverheads() noexcept
void set(int indexToChange, ObjectClass *newObject)
ObjectClass *const * begin() const noexcept
ObjectClass * insert(int indexToInsertAt, const ObjectClassPtr &newObject)
ReferenceCountedArray()=default
bool operator!=(const ReferenceCountedArray< ObjectClass, TypeOfCriticalSectionToUse > &other) const noexcept
int indexOfSorted(ElementComparator &comparator, const ObjectClass *objectToLookFor) const noexcept
typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType
bool addIfNotAlreadyThere(ObjectClass *newObject)
ObjectClassPtr operator[](int index) const noexcept
void remove(int indexToRemove)
void sort(ElementComparator &comparator, bool retainOrderOfEquivalentItems=false) noexcept
ReferenceCountedArray(const ReferenceCountedArray< OtherObjectClass, OtherCriticalSection > &other) noexcept
bool operator==(const ReferenceCountedArray &other) const noexcept
void removeObject(ObjectClass *objectToRemove)
ObjectClass * getObjectPointer(int index) const noexcept
void swap(int index1, int index2) noexcept
ObjectClassPtr getFirst() const noexcept
void ensureStorageAllocated(const int minNumElements)
void set(int indexToChange, const ObjectClassPtr &newObject)
ObjectClass *const * data() const noexcept
const TypeOfCriticalSectionToUse & getLock() const noexcept
ObjectClassPtr getUnchecked(int index) const noexcept
ObjectClass ** begin() noexcept
void addOrReplaceSorted(ElementComparator &comparator, ObjectClass *newObject) noexcept
bool contains(const ObjectClass *objectToLookFor) const noexcept
void removeRange(int startIndex, int numberToRemove)
ObjectClass * getObjectPointerUnchecked(int index) const noexcept
void move(int currentIndex, int newIndex) noexcept
ObjectClassPtr removeAndReturn(int indexToRemove)
ReferenceCountedArray & operator=(const ReferenceCountedArray &other) noexcept
ObjectClass ** end() noexcept
ObjectClass ** getRawDataPointer() const noexcept
bool contains(const ObjectClassPtr &objectToLookFor) const noexcept
ObjectClass ** data() noexcept
void swapWith(OtherArrayType &otherArray) noexcept
bool addIfNotAlreadyThere(const ObjectClassPtr &newObject)
int addSorted(ElementComparator &comparator, ObjectClass *newObject) noexcept
int indexOf(const ObjectClassPtr &objectToLookFor) const noexcept
ObjectClassPtr getLast() const noexcept
void addArray(const ReferenceCountedArray &arrayToAddFrom, int startIndex=0, int numElementsToAdd=-1) noexcept
ObjectClass * insert(int indexToInsertAt, ObjectClass *newObject)
ObjectClass * add(ObjectClass *newObject)
void removeObject(const ObjectClassPtr &objectToRemove)