LMMS
Loading...
Searching...
No Matches
water::ArrayAllocationBase< ElementType > Class Template Reference

#include <ArrayAllocationBase.h>

Public Member Functions

 ArrayAllocationBase () noexcept
 ~ArrayAllocationBase () noexcept
bool setAllocatedSize (const size_t numNewElements) noexcept
bool ensureAllocatedSize (const size_t minNumElements) noexcept
bool shrinkToNoMoreThan (const size_t maxNumElements) noexcept
void swapWith (ArrayAllocationBase< ElementType > &other) noexcept
void moveMemory (ElementType *target, const ElementType *source, const size_t numElements) noexcept

Public Attributes

HeapBlock< ElementType > elements
size_t numAllocated

Detailed Description

template<class ElementType>
class water::ArrayAllocationBase< ElementType >

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.

See also
Array, OwnedArray, ReferenceCountedArray

Constructor & Destructor Documentation

◆ ArrayAllocationBase()

template<class ElementType>
water::ArrayAllocationBase< ElementType >::ArrayAllocationBase ( )
inlinenoexcept

Creates an empty array.

◆ ~ArrayAllocationBase()

template<class ElementType>
water::ArrayAllocationBase< ElementType >::~ArrayAllocationBase ( )
inlinenoexcept

Destructor.

Member Function Documentation

◆ ensureAllocatedSize()

template<class ElementType>
bool water::ArrayAllocationBase< ElementType >::ensureAllocatedSize ( const size_t minNumElements)
inlinenoexcept

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

◆ moveMemory()

template<class ElementType>
void water::ArrayAllocationBase< ElementType >::moveMemory ( ElementType * target,
const ElementType * source,
const size_t numElements )
inlinenoexcept

◆ setAllocatedSize()

template<class ElementType>
bool water::ArrayAllocationBase< ElementType >::setAllocatedSize ( const size_t numNewElements)
inlinenoexcept

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
numNewElementsthe number of elements that are needed

◆ shrinkToNoMoreThan()

template<class ElementType>
bool water::ArrayAllocationBase< ElementType >::shrinkToNoMoreThan ( const size_t maxNumElements)
inlinenoexcept

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

◆ swapWith()

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

Swap the contents of two objects.

Member Data Documentation

◆ elements

template<class ElementType>
HeapBlock<ElementType> water::ArrayAllocationBase< ElementType >::elements

◆ numAllocated

template<class ElementType>
size_t water::ArrayAllocationBase< ElementType >::numAllocated

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