36template <
class ElementType,
class TypeOfCriticalSectionToUse>
48 : elements (std::move (other.elements)),
49 numAllocated (other.numAllocated)
55 elements = std::move (other.elements);
56 numAllocated = other.numAllocated;
70 if (numAllocated != numElements)
73 elements.realloc ((
size_t) numElements);
77 numAllocated = numElements;
91 if (minNumElements > numAllocated)
94 jassert (numAllocated <= 0 || elements !=
nullptr);
102 if (maxNumElements < numAllocated)
109 elements.swapWith (other.elements);
110 std::swap (numAllocated, other.numAllocated);
115 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.