ArrayBase< ElementType, TypeOfCriticalSectionToUse > Class Template Reference
juce_core » containers

A basic object container. More...

Inherits TypeOfCriticalSectionToUse.

## Public Member Functions

| ArrayBase ()=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. More...
template<class OtherElementType , class OtherCriticalSection , typename = AllowConversion<OtherElementType, OtherCriticalSection>>
ArrayBase & | operator= (ArrayBase< OtherElementType, OtherCriticalSection > &&other) noexcept
| Converting move assignment operator. More...
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<! std::is_pointer< OtherArrayType >::value, int >::type | 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

## Detailed Description

### template<class ElementType, class TypeOfCriticalSectionToUse>
class 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

## Constructor & Destructor Documentation

## ArrayBase() [1/3]

template<class ElementType, class TypeOfCriticalSectionToUse>

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

default

## ~ArrayBase()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

## ArrayBase() [2/3]

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

## ArrayBase() [3/3]

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

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

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.

## Member Function Documentation

## operator=() [1/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

## operator=() [2/2]

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

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

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.

## operator==()

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

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

noexcept

Referenced by ArrayBase< ProgressBar *, DummyCriticalSection >::operator!=().

## operator!=()

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

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

noexcept

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

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

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

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

## getValueWithDefault()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

Referenced by ReferenceCountedArray< AudioProcessorGraph::Node >::getObjectPointer(), and OwnedArray< MarkerList::Marker >::operator[]().

## getFirst()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

Referenced by OwnedArray< MarkerList::Marker >::getFirst(), and ReferenceCountedArray< AudioProcessorGraph::Node >::getFirst().

## getLast()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

Referenced by OwnedArray< MarkerList::Marker >::getLast(), and ReferenceCountedArray< AudioProcessorGraph::Node >::getLast().

## begin() [1/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

Referenced by OwnedArray< MarkerList::Marker >::begin(), ReferenceCountedArray< AudioProcessorGraph::Node >::begin(), OwnedArray< MarkerList::Marker >::contains(), ReferenceCountedArray< AudioProcessorGraph::Node >::contains(), OwnedArray< MarkerList::Marker >::getRawDataPointer(), ReferenceCountedArray< AudioProcessorGraph::Node >::getRawDataPointer(), OwnedArray< MarkerList::Marker >::indexOf(), ReferenceCountedArray< AudioProcessorGraph::Node >::indexOf(), ArrayBase< ProgressBar *, DummyCriticalSection >::operator==(), OwnedArray< MarkerList::Marker >::remove(), ReferenceCountedArray< AudioProcessorGraph::Node >::remove(), ReferenceCountedArray< AudioProcessorGraph::Node >::removeAndReturn(), OwnedArray< MarkerList::Marker >::removeRange(), and ReferenceCountedArray< AudioProcessorGraph::Node >::removeRange().

## begin() [2/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

## end() [1/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

Referenced by ReferenceCountedArray< AudioProcessorGraph::Node >::addArray(), OwnedArray< MarkerList::Marker >::contains(), ReferenceCountedArray< AudioProcessorGraph::Node >::contains(), OwnedArray< MarkerList::Marker >::end(), ReferenceCountedArray< AudioProcessorGraph::Node >::end(), OwnedArray< MarkerList::Marker >::indexOf(), and ReferenceCountedArray< AudioProcessorGraph::Node >::indexOf().

## end() [2/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

## data() [1/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

## data() [2/2]

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

## size()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

Referenced by OwnedArray< MarkerList::Marker >::addCopiesOf(), OwnedArray< MarkerList::Marker >::indexOfSorted(), ReferenceCountedArray< AudioProcessorGraph::Node >::indexOfSorted(), OwnedArray< MarkerList::Marker >::minimiseStorageOverheads(), ReferenceCountedArray< AudioProcessorGraph::Node >::minimiseStorageOverheads(), ArrayBase< ProgressBar *, DummyCriticalSection >::operator==(), OwnedArray< MarkerList::Marker >::remove(), ReferenceCountedArray< AudioProcessorGraph::Node >::remove(), OwnedArray< MarkerList::Marker >::removeAndReturn(), ReferenceCountedArray< AudioProcessorGraph::Node >::removeAndReturn(), OwnedArray< MarkerList::Marker >::removeLast(), ReferenceCountedArray< AudioProcessorGraph::Node >::removeLast(), OwnedArray< MarkerList::Marker >::removeObject(), OwnedArray< MarkerList::Marker >::removeRange(), ReferenceCountedArray< AudioProcessorGraph::Node >::removeRange(), OwnedArray< MarkerList::Marker >::set(), ReferenceCountedArray< AudioProcessorGraph::Node >::set(), OwnedArray< MarkerList::Marker >::size(), ReferenceCountedArray< AudioProcessorGraph::Node >::size(), and ReferenceCountedArray< AudioProcessorGraph::Node >::swap().

## capacity()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

Referenced by OwnedArray< MarkerList::Marker >::remove(), ReferenceCountedArray< AudioProcessorGraph::Node >::remove(), OwnedArray< MarkerList::Marker >::removeAndReturn(), ReferenceCountedArray< AudioProcessorGraph::Node >::removeAndReturn(), OwnedArray< MarkerList::Marker >::removeRange(), and ReferenceCountedArray< AudioProcessorGraph::Node >::removeRange().

## setAllocatedSize()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

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

## ensureAllocatedSize()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

Referenced by ArrayBase< ProgressBar *, DummyCriticalSection >::add(), ArrayBase< ProgressBar *, DummyCriticalSection >::addArray(), OwnedArray< MarkerList::Marker >::addCopiesOf(), OwnedArray< MarkerList::Marker >::ensureStorageAllocated(), and ReferenceCountedArray< AudioProcessorGraph::Node >::ensureStorageAllocated().

## shrinkToNoMoreThan()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

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

## clear()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

Referenced by OwnedArray< MarkerList::Marker >::clearQuick(), and ArrayBase< ProgressBar *, DummyCriticalSection >::~ArrayBase().

## swapWith()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

Referenced by ArrayBase< ProgressBar *, DummyCriticalSection >::operator=(), OwnedArray< MarkerList::Marker >::swapWith(), and ReferenceCountedArray< AudioProcessorGraph::Node >::swapWith().

## add() [1/4]

template<class ElementType, class TypeOfCriticalSectionToUse>

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

Referenced by OwnedArray< MarkerList::Marker >::add(), ReferenceCountedArray< AudioProcessorGraph::Node >::add(), OwnedArray< MarkerList::Marker >::addCopiesOf(), OwnedArray< MarkerList::Marker >::set(), and ReferenceCountedArray< AudioProcessorGraph::Node >::set().

## add() [2/4]

template<class ElementType, class TypeOfCriticalSectionToUse>

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

## add() [3/4]

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

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

## add() [4/4]

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

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

## addArray() [1/4]

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

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

Referenced by ArrayBase< ProgressBar *, DummyCriticalSection >::addArray(), OwnedArray< MarkerList::Marker >::addArray(), ReferenceCountedArray< AudioProcessorGraph::Node >::addArray(), and ReferenceCountedArray< AudioProcessorGraph::Node >::ReferenceCountedArray().

## addArray() [2/4]

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

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

## addArray() [3/4]

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

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

## addArray() [4/4]

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

std::enable_if<! std::is_pointer<OtherArrayType>::value, int>::type ArrayBase< ElementType, TypeOfCriticalSectionToUse >::addArray | ( | const OtherArrayType & | arrayToAddFrom,
|  | int | startIndex,
|  | int | numElementsToAdd = `-1`
| ) |  |

## insert()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

Referenced by OwnedArray< MarkerList::Marker >::insert(), and ReferenceCountedArray< AudioProcessorGraph::Node >::insert().

## insertArray()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

Referenced by OwnedArray< MarkerList::Marker >::insertArray().

## removeElements()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

Referenced by OwnedArray< MarkerList::Marker >::remove(), ReferenceCountedArray< AudioProcessorGraph::Node >::remove(), OwnedArray< MarkerList::Marker >::removeAndReturn(), ReferenceCountedArray< AudioProcessorGraph::Node >::removeAndReturn(), OwnedArray< MarkerList::Marker >::removeRange(), and ReferenceCountedArray< AudioProcessorGraph::Node >::removeRange().

## swap()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

Referenced by OwnedArray< MarkerList::Marker >::swap().

## move()

template<class ElementType, class TypeOfCriticalSectionToUse>

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

noexcept

Referenced by OwnedArray< MarkerList::Marker >::move(), and ReferenceCountedArray< AudioProcessorGraph::Node >::move().

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

- juce_ArrayBase.h