JUCE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Public Attributes | List of all members
ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse > Class Template Reference

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

Inherits TypeOfCriticalSectionToUse.

Public Member Functions

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

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

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

Creates an empty array.

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

Destructor.

Member Function Documentation

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

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< SynthesiserSound >::clear(), ArrayAllocationBase< ProgressBar *, DummyCriticalSection >::ensureAllocatedSize(), ReferenceCountedArray< SynthesiserSound >::ReferenceCountedArray(), and ArrayAllocationBase< ProgressBar *, DummyCriticalSection >::shrinkToNoMoreThan().

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

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< SynthesiserSound >::add(), ReferenceCountedArray< SynthesiserSound >::addArray(), OwnedArray< MidiBuffer >::addArray(), OwnedArray< MidiBuffer >::addCopiesOf(), OwnedArray< MidiBuffer >::ensureStorageAllocated(), ReferenceCountedArray< SynthesiserSound >::ensureStorageAllocated(), OwnedArray< MidiBuffer >::insert(), ReferenceCountedArray< SynthesiserSound >::insert(), OwnedArray< MidiBuffer >::insertArray(), OwnedArray< MidiBuffer >::set(), and ReferenceCountedArray< SynthesiserSound >::set().

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

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< SynthesiserSound >::minimiseStorageOverheads().

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

Member Data Documentation

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

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

template<class ElementType, class TypeOfCriticalSectionToUse>
int ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::numAllocated

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