Loading...
Searching...
No Matches
juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse > Class Template Reference

## Detailed Description

template<class ElementType, class TypeOfCriticalSectionToUse>
class juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >

A basic object container.

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

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

- juce_core/containers/juce_ArrayBase.h

Inherits TypeOfCriticalSectionToUse.

## Public Member Functions

| ArrayBase () noexcept=default
| ~ArrayBase ()
| ArrayBase (ArrayBase &&other) noexcept
ArrayBase & | operator= (ArrayBase &&other) noexcept
template<class OtherElementType, class OtherCriticalSection, typename = AllowConversion<OtherElementType, OtherCriticalSection>>
| ArrayBase (ArrayBase< OtherElementType, OtherCriticalSection > &&other) noexcept
| Converting move constructor.
template<class OtherElementType, class OtherCriticalSection, typename = AllowConversion<OtherElementType, OtherCriticalSection>>
ArrayBase & | operator= (ArrayBase< OtherElementType, OtherCriticalSection > &&other) noexcept
| Converting move assignment operator.
template<class OtherArrayType>
bool | operator== (const OtherArrayType &other) const noexcept
template<class OtherArrayType>
bool | operator!= (const OtherArrayType &other) const noexcept
ElementType & | operator[] (const int index) noexcept
const ElementType & | operator[] (const int index) const noexcept
ElementType | getValueWithDefault (const int index) const noexcept
ElementType | getFirst () const noexcept
ElementType | getLast () const noexcept
ElementType * | begin () noexcept
const ElementType * | begin () const noexcept
ElementType * | end () noexcept
const ElementType * | end () const noexcept
ElementType * | data () noexcept
const ElementType * | data () const noexcept
int | size () const noexcept
int | capacity () const noexcept
void | setAllocatedSize (int numElements)
void | ensureAllocatedSize (int minNumElements)
void | shrinkToNoMoreThan (int maxNumElements)
void | clear ()
void | swapWith (ArrayBase &other) noexcept
void | add (const ElementType &newElement)
void | add (ElementType &&newElement)
template<typename... OtherElements>
void | add (const ElementType &firstNewElement, OtherElements &&... otherElements)
template<typename... OtherElements>
void | add (ElementType &&firstNewElement, OtherElements &&... otherElements)
template<typename Type>
void | addArray (const Type *elementsToAdd, int numElementsToAdd)
template<typename TypeToCreateFrom>
void | addArray (const std::initializer_list< TypeToCreateFrom > &items)
template<class OtherArrayType>
void | addArray (const OtherArrayType &arrayToAddFrom)
template<class OtherArrayType>
std::enable_if_t<! std::is_pointer_v< OtherArrayType >, int > | addArray (const OtherArrayType &arrayToAddFrom, int startIndex, int numElementsToAdd=-1)
void | insert (int indexToInsertAt, ParameterType newElement, int numberOfTimesToInsertIt)
void | insertArray (int indexToInsertAt, const ElementType *newElements, int numberOfElements)
void | removeElements (int indexToRemoveAt, int numElementsToRemove)
void | swap (int index1, int index2)
void | move (int currentIndex, int newIndex) noexcept

## Constructors and Destructors

## ArrayBase() [1/3]

template<class ElementType, class TypeOfCriticalSectionToUse>

juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::ArrayBase | ( |  | ) |

default noexcept

## ~ArrayBase()

template<class ElementType, class TypeOfCriticalSectionToUse>

juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::~ArrayBase | ( |  | ) |

inline

References ArrayBase, and clear().

## ArrayBase() [2/3]

template<class ElementType, class TypeOfCriticalSectionToUse>

juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::ArrayBase | ( | ArrayBase< ElementType, TypeOfCriticalSectionToUse > && | other | ) |

inline noexcept

References ArrayBase.

## ArrayBase() [3/3]

template<class ElementType, class TypeOfCriticalSectionToUse>
template<class OtherElementType, class OtherCriticalSection, typename = AllowConversion<OtherElementType, OtherCriticalSection>>

juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::ArrayBase | ( | ArrayBase< OtherElementType, OtherCriticalSection > && | other | ) |

inline noexcept

Converting move constructor.

Only enabled when the other array has a different type to this one. If you see a compile error here, it's probably because you're attempting a conversion that HeapBlock won't allow.

References ArrayBase.

## Member Functions

## operator=() [1/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

ArrayBase & juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::operator= | ( | ArrayBase< ElementType, TypeOfCriticalSectionToUse > && | other | ) |

inline noexcept

References ArrayBase, and swapWith().

## operator=() [2/2]

template<class ElementType, class TypeOfCriticalSectionToUse>
template<class OtherElementType, class OtherCriticalSection, typename = AllowConversion<OtherElementType, OtherCriticalSection>>

ArrayBase & juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::operator= | ( | ArrayBase< OtherElementType, OtherCriticalSection > && | other | ) |

inline noexcept

Converting move assignment operator.

Only enabled when the other array has a different type to this one. If you see a compile error here, it's probably because you're attempting a conversion that HeapBlock won't allow.

References ArrayBase.

## operator==()

template<class ElementType, class TypeOfCriticalSectionToUse>
template<class OtherArrayType>

bool juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::operator== | ( | const OtherArrayType & | other | ) | const

inline noexcept

References begin(), juce::exactlyEqual(), and size().

Referenced by operator!=().

## operator!=()

template<class ElementType, class TypeOfCriticalSectionToUse>
template<class OtherArrayType>

bool juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::operator!= | ( | const OtherArrayType & | other | ) | const

inline noexcept

References operator==().

## operator[]() [1/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

ElementType & juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::operator[] | ( | const int | index | ) |

inline noexcept

References juce::isPositiveAndBelow(), and jassert.

## operator[]() [2/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

const ElementType & juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::operator[] | ( | const int | index | ) | const

inline noexcept

References juce::isPositiveAndBelow(), and jassert.

## getValueWithDefault()

template<class ElementType, class TypeOfCriticalSectionToUse>

ElementType juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::getValueWithDefault | ( | const int | index | ) | const

inline noexcept

References juce::isPositiveAndBelow().

## getFirst()

template<class ElementType, class TypeOfCriticalSectionToUse>

ElementType juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::getFirst | ( |  | ) | const

inline noexcept

## getLast()

template<class ElementType, class TypeOfCriticalSectionToUse>

ElementType juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::getLast | ( |  | ) | const

inline noexcept

## begin() [1/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

ElementType * juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::begin | ( |  | ) |

inline noexcept

Referenced by operator==().

## begin() [2/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

const ElementType * juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::begin | ( |  | ) | const

inline noexcept

## end() [1/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

ElementType * juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::end | ( |  | ) |

inline noexcept

## end() [2/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

const ElementType * juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::end | ( |  | ) | const

inline noexcept

## data() [1/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

ElementType * juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::data | ( |  | ) |

inline noexcept

## data() [2/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

const ElementType * juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::data | ( |  | ) | const

inline noexcept

## size()

template<class ElementType, class TypeOfCriticalSectionToUse>

int juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::size | ( |  | ) | const

inline noexcept

Referenced by operator==().

## capacity()

template<class ElementType, class TypeOfCriticalSectionToUse>

int juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::capacity | ( |  | ) | const

inline noexcept

## setAllocatedSize()

template<class ElementType, class TypeOfCriticalSectionToUse>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::setAllocatedSize | ( | int | numElements | ) |

inline

References jassert.

Referenced by ensureAllocatedSize(), and shrinkToNoMoreThan().

## ensureAllocatedSize()

template<class ElementType, class TypeOfCriticalSectionToUse>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::ensureAllocatedSize | ( | int | minNumElements | ) |

inline

References jassert, and setAllocatedSize().

Referenced by addArray(), addArray(), and addArray().

## shrinkToNoMoreThan()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

inline

References setAllocatedSize().

## clear()

template<class ElementType, class TypeOfCriticalSectionToUse>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::clear | ( |  | ) |

inline

Referenced by ~ArrayBase().

## swapWith()

template<class ElementType, class TypeOfCriticalSectionToUse>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::swapWith | ( | ArrayBase< ElementType, TypeOfCriticalSectionToUse > & | other | ) |

inline noexcept

References ArrayBase.

Referenced by operator=().

## add() [1/4]

template<class ElementType, class TypeOfCriticalSectionToUse>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::add | ( | const ElementType & | newElement | ) |

inline

## add() [2/4]

template<class ElementType, class TypeOfCriticalSectionToUse>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::add | ( | ElementType && | newElement | ) |

inline

## add() [3/4]

template<class ElementType, class TypeOfCriticalSectionToUse>
template<typename... OtherElements>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::add | ( | const ElementType & | firstNewElement,
|  | OtherElements &&... | otherElements )

inline

## add() [4/4]

template<class ElementType, class TypeOfCriticalSectionToUse>
template<typename... OtherElements>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::add | ( | ElementType && | firstNewElement,
|  | OtherElements &&... | otherElements )

inline

## addArray() [1/4]

template<class ElementType, class TypeOfCriticalSectionToUse>
template<typename Type>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::addArray | ( | const Type * | elementsToAdd,
|  | int | numElementsToAdd )

inline

References ensureAllocatedSize().

Referenced by addArray().

## addArray() [2/4]

template<class ElementType, class TypeOfCriticalSectionToUse>
template<typename TypeToCreateFrom>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::addArray | ( | const std::initializer_list< TypeToCreateFrom > & | items | ) |

inline

References ensureAllocatedSize().

## addArray() [3/4]

template<class ElementType, class TypeOfCriticalSectionToUse>
template<class OtherArrayType>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::addArray | ( | const OtherArrayType & | arrayToAddFrom | ) |

inline

References ensureAllocatedSize(), and jassert.

## addArray() [4/4]

template<class ElementType, class TypeOfCriticalSectionToUse>
template<class OtherArrayType>

std::enable_if_t<! std::is_pointer_v< OtherArrayType >, int > juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::addArray | ( | const OtherArrayType & | arrayToAddFrom,
|  | int | startIndex,
|  | int | numElementsToAdd = -1 )

inline

References addArray(), jassert, and jassertfalse.

## insert()

template<class ElementType, class TypeOfCriticalSectionToUse>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::insert | ( | int | indexToInsertAt,
|  | ParameterType | newElement,
|  | int | numberOfTimesToInsertIt )

inline

## insertArray()

template<class ElementType, class TypeOfCriticalSectionToUse>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::insertArray | ( | int | indexToInsertAt,
|  | const ElementType * | newElements,
|  | int | numberOfElements )

inline

## removeElements()

template<class ElementType, class TypeOfCriticalSectionToUse>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::removeElements | ( | int | indexToRemoveAt,
|  | int | numElementsToRemove )

inline

References jassert.

## swap()

template<class ElementType, class TypeOfCriticalSectionToUse>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::swap | ( | int | index1,
|  | int | index2 )

inline

References juce::isPositiveAndBelow().

## move()

template<class ElementType, class TypeOfCriticalSectionToUse>

void juce::ArrayBase< ElementType, TypeOfCriticalSectionToUse >::move | ( | int | currentIndex,
|  | int | newIndex )

inline noexcept

References juce::isPositiveAndBelow().

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited