JUCE  v5.1.1-3-g1a0b28c73
JUCE API
ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse > Class Template Reference

Implements some basic array storage allocation functions. More...

#include <juce_ArrayAllocationBase.h>

Inherits TypeOfCriticalSectionToUse.

Collaboration diagram for ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >:

Public Member Functions

 ArrayAllocationBase () noexcept
 Creates an empty array. More...
 
 ArrayAllocationBase (ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse > &&other) noexcept
 
 ~ArrayAllocationBase () noexcept
 Destructor. More...
 
void ensureAllocatedSize (const int minNumElements)
 Increases the amount of storage allocated if it is less than a given amount. More...
 
ArrayAllocationBaseoperator= (ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse > &&other) noexcept
 
void setAllocatedSize (const int numElements)
 Changes the amount of storage allocated. More...
 
void shrinkToNoMoreThan (const int maxNumElements)
 Minimises the amount of storage allocated so that it's no more than the given number of elements. More...
 
void swapWith (ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse > &other) noexcept
 Swap the contents of two objects. More...
 

Public Attributes

HeapBlock< ElementType > elements
 
int numAllocated
 

Detailed Description

template<class ElementType, class TypeOfCriticalSectionToUse>
class ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >

Implements some basic array storage allocation functions.

This class isn't really for public use - it's used by the other array classes, but might come in handy for some purposes.

It inherits from a critical section class to allow the arrays to use the "empty base class optimisation" pattern to reduce their footprint.

See also
Array, OwnedArray, ReferenceCountedArray

Constructor & Destructor Documentation

◆ ArrayAllocationBase() [1/2]

template<class ElementType, class TypeOfCriticalSectionToUse>
ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::ArrayAllocationBase ( )
inlinenoexcept

Creates an empty array.

◆ ~ArrayAllocationBase()

template<class ElementType, class TypeOfCriticalSectionToUse>
ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::~ArrayAllocationBase ( )
inlinenoexcept

Destructor.

◆ ArrayAllocationBase() [2/2]

template<class ElementType, class TypeOfCriticalSectionToUse>
ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::ArrayAllocationBase ( ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse > &&  other)
inlinenoexcept

Member Function Documentation

◆ ensureAllocatedSize()

template<class ElementType, class TypeOfCriticalSectionToUse>
void ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::ensureAllocatedSize ( const int  minNumElements)
inline

Increases the amount of storage allocated if it is less than a given amount.

This will retain any data currently held in the array, but will add extra space at the end to make sure there it's at least as big as the size passed in. If it's already bigger, no action is taken.

Parameters
minNumElementsthe minimum number of elements that are needed

Referenced by OwnedArray< MidiBuffer >::add(), ReferenceCountedArray< AudioProcessorGraph::Node >::add(), ReferenceCountedArray< AudioProcessorGraph::Node >::addArray(), OwnedArray< MidiBuffer >::addArray(), OwnedArray< MidiBuffer >::addCopiesOf(), OwnedArray< MidiBuffer >::ensureStorageAllocated(), ReferenceCountedArray< AudioProcessorGraph::Node >::ensureStorageAllocated(), OwnedArray< MidiBuffer >::insert(), ReferenceCountedArray< AudioProcessorGraph::Node >::insert(), OwnedArray< MidiBuffer >::insertArray(), OwnedArray< MidiBuffer >::set(), and ReferenceCountedArray< AudioProcessorGraph::Node >::set().

◆ operator=()

template<class ElementType, class TypeOfCriticalSectionToUse>
ArrayAllocationBase& ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::operator= ( ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse > &&  other)
inlinenoexcept

◆ setAllocatedSize()

template<class ElementType, class TypeOfCriticalSectionToUse>
void ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::setAllocatedSize ( const int  numElements)
inline

Changes the amount of storage allocated.

This will retain any data currently held in the array, and either add or remove extra space at the end.

Parameters
numElementsthe number of elements that are needed

Referenced by OwnedArray< MidiBuffer >::clear(), ReferenceCountedArray< AudioProcessorGraph::Node >::clear(), ArrayAllocationBase< ProgressBar *, DummyCriticalSection >::ensureAllocatedSize(), ReferenceCountedArray< AudioProcessorGraph::Node >::ReferenceCountedArray(), and ArrayAllocationBase< ProgressBar *, DummyCriticalSection >::shrinkToNoMoreThan().

◆ shrinkToNoMoreThan()

template<class ElementType, class TypeOfCriticalSectionToUse>
void ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::shrinkToNoMoreThan ( const int  maxNumElements)
inline

Minimises the amount of storage allocated so that it's no more than the given number of elements.

Referenced by OwnedArray< MidiBuffer >::minimiseStorageOverheads(), and ReferenceCountedArray< AudioProcessorGraph::Node >::minimiseStorageOverheads().

◆ swapWith()

template<class ElementType, class TypeOfCriticalSectionToUse>
void ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::swapWith ( ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse > &  other)
inlinenoexcept

Member Data Documentation

◆ elements

template<class ElementType, class TypeOfCriticalSectionToUse>
HeapBlock<ElementType> ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::elements

Referenced by OwnedArray< MidiBuffer >::add(), ReferenceCountedArray< AudioProcessorGraph::Node >::add(), OwnedArray< MidiBuffer >::addArray(), OwnedArray< MidiBuffer >::addCopiesOf(), ReferenceCountedArray< AudioProcessorGraph::Node >::addOrReplaceSorted(), ReferenceCountedArray< AudioProcessorGraph::Node >::addSorted(), OwnedArray< MidiBuffer >::addSorted(), OwnedArray< MidiBuffer >::begin(), ReferenceCountedArray< AudioProcessorGraph::Node >::begin(), OwnedArray< MidiBuffer >::contains(), ReferenceCountedArray< AudioProcessorGraph::Node >::contains(), OwnedArray< MidiBuffer >::deleteAllObjects(), OwnedArray< MidiBuffer >::end(), ReferenceCountedArray< AudioProcessorGraph::Node >::end(), ArrayAllocationBase< ProgressBar *, DummyCriticalSection >::ensureAllocatedSize(), OwnedArray< MidiBuffer >::getFirst(), ReferenceCountedArray< AudioProcessorGraph::Node >::getFirst(), OwnedArray< MidiBuffer >::getLast(), ReferenceCountedArray< AudioProcessorGraph::Node >::getLast(), ReferenceCountedArray< AudioProcessorGraph::Node >::getObjectPointer(), ReferenceCountedArray< AudioProcessorGraph::Node >::getObjectPointerUnchecked(), OwnedArray< MidiBuffer >::getRawDataPointer(), ReferenceCountedArray< AudioProcessorGraph::Node >::getRawDataPointer(), OwnedArray< MidiBuffer >::getUnchecked(), OwnedArray< MidiBuffer >::indexOf(), ReferenceCountedArray< AudioProcessorGraph::Node >::indexOf(), ReferenceCountedArray< AudioProcessorGraph::Node >::indexOfSorted(), OwnedArray< MidiBuffer >::indexOfSorted(), OwnedArray< MidiBuffer >::insert(), ReferenceCountedArray< AudioProcessorGraph::Node >::insert(), OwnedArray< MidiBuffer >::insertArray(), ReferenceCountedArray< AudioProcessorGraph::Node >::move(), OwnedArray< MidiBuffer >::move(), ArrayAllocationBase< ProgressBar *, DummyCriticalSection >::operator=(), ReferenceCountedArray< AudioProcessorGraph::Node >::operator==(), OwnedArray< MidiBuffer >::operator[](), ReferenceCountedArray< AudioProcessorGraph::Node >::ReferenceCountedArray(), ReferenceCountedArray< AudioProcessorGraph::Node >::releaseAllObjects(), ReferenceCountedArray< AudioProcessorGraph::Node >::remove(), OwnedArray< MidiBuffer >::remove(), ReferenceCountedArray< AudioProcessorGraph::Node >::removeAndReturn(), OwnedArray< MidiBuffer >::removeAndReturn(), OwnedArray< MidiBuffer >::removeObject(), ReferenceCountedArray< AudioProcessorGraph::Node >::removeRange(), OwnedArray< MidiBuffer >::removeRange(), OwnedArray< MidiBuffer >::set(), ReferenceCountedArray< AudioProcessorGraph::Node >::set(), ArrayAllocationBase< ProgressBar *, DummyCriticalSection >::setAllocatedSize(), ReferenceCountedArray< AudioProcessorGraph::Node >::sort(), OwnedArray< MidiBuffer >::sort(), ReferenceCountedArray< AudioProcessorGraph::Node >::swap(), OwnedArray< MidiBuffer >::swap(), and ArrayAllocationBase< ProgressBar *, DummyCriticalSection >::swapWith().

◆ numAllocated


The documentation for this class was generated from the following file: