40template <
class ElementType,
class TypeOfCriticalSectionToUse>
52 : elements (std::move (other.elements)),
53 numAllocated (other.numAllocated)
59 elements = std::move (other.elements);
60 numAllocated = other.numAllocated;
74 if (numAllocated != numElements)
77 elements.realloc ((
size_t) numElements);
81 numAllocated = numElements;
95 if (minNumElements > numAllocated)
98 jassert (numAllocated <= 0 || elements !=
nullptr);
106 if (maxNumElements < numAllocated)
113 elements.swapWith (other.elements);
114 std::swap (numAllocated, other.numAllocated);
119 int numAllocated = 0;
Implements some basic array storage allocation functions.
void shrinkToNoMoreThan(int maxNumElements)
Minimises the amount of storage allocated so that it's no more than the given number of elements.
ArrayAllocationBase()=default
Creates an empty array.
~ArrayAllocationBase()=default
Destructor.
void ensureAllocatedSize(int minNumElements)
Increases the amount of storage allocated if it is less than a given amount.
void setAllocatedSize(int numElements)
Changes the amount of storage allocated.
void swapWith(ArrayAllocationBase &other) noexcept
Swap the contents of two objects.
Very simple container class to hold a pointer to some data on the heap.