JUCE: ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse > Class Template Reference

JUCE

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

## Public Attributes
HeapBlock< ElementType > | elements
int | numAllocated = 0

## 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 used to be part of the container classes but has since been superseded by ArrayBase. Eventually it will be removed from the API.

## Constructor & Destructor Documentation

## ◆ ArrayAllocationBase() [1/2]

template<class ElementType , class TypeOfCriticalSectionToUse >

ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::ArrayAllocationBase | ( |  | ) |
| default

Creates an empty array.

## ◆ ~ArrayAllocationBase()

template<class ElementType , class TypeOfCriticalSectionToUse >

ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::~ArrayAllocationBase | ( |  | ) |
| default

Destructor.

## ◆ ArrayAllocationBase() [2/2]

template<class ElementType , class TypeOfCriticalSectionToUse >

ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::ArrayAllocationBase | ( | ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse > && | other | ) |
| noexcept

## Member Function Documentation

## ◆ operator=()

template<class ElementType , class TypeOfCriticalSectionToUse >

ArrayAllocationBase& ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::operator= | ( | ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse > && | other | ) |
| noexcept

References ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::elements, and ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::numAllocated.

## ◆ setAllocatedSize()

template<class ElementType , class TypeOfCriticalSectionToUse >

void ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::setAllocatedSize | ( | 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

  numElements | the number of elements that are needed

References ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::elements, HeapBlock< ElementType, throwOnFailure >::free(), ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::numAllocated, and HeapBlock< ElementType, throwOnFailure >::realloc().

Referenced by ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::ensureAllocatedSize(), and ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::shrinkToNoMoreThan().

## ◆ ensureAllocatedSize()

template<class ElementType , class TypeOfCriticalSectionToUse >

void ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::ensureAllocatedSize | ( | 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

  minNumElements | the minimum number of elements that are needed

References ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::elements, jassert, ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::numAllocated, and ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::setAllocatedSize().

## ◆ shrinkToNoMoreThan()

template<class ElementType , class TypeOfCriticalSectionToUse >

void ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::shrinkToNoMoreThan | ( | int | maxNumElements | ) |

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

References ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::numAllocated, and ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::setAllocatedSize().

## ◆ swapWith()

template<class ElementType , class TypeOfCriticalSectionToUse >

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

Swap the contents of two objects.

References ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::elements, ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::numAllocated, and HeapBlock< ElementType, throwOnFailure >::swapWith().

## Member Data Documentation

## ◆ elements

template<class ElementType , class TypeOfCriticalSectionToUse >

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

Referenced by ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::ensureAllocatedSize(), ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::operator=(), ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::setAllocatedSize(), and ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::swapWith().

## ◆ numAllocated

template<class ElementType , class TypeOfCriticalSectionToUse >

int ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::numAllocated = 0

Referenced by ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::ensureAllocatedSize(), ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::operator=(), ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::setAllocatedSize(), ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::shrinkToNoMoreThan(), and ArrayAllocationBase< ElementType, TypeOfCriticalSectionToUse >::swapWith().

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

- juce_ArrayAllocationBase.h