MPD: ReusableArray< T, M > Class Template Reference

MPD 0.20.18

Public Member Functions
ReusableArray< T, M > Class Template Reference

Manager for a temporary array which grows as needed. More...

`#include <ReusableArray.hxx>`

## Public Member Functions
| ReusableArray ()=default
| ReusableArray (ReusableArray &&src)
ReusableArray & | operator= (ReusableArray &&src)
| ~ReusableArray ()
size_t | GetCapacity () const
void | Clear ()
| Free resources allocated by this object. More...
gcc_malloc T * | Get (size_t size)
| Get the buffer, and guarantee a minimum size. More...

## Detailed Description

### template<typename T, size_t M = 1>
class ReusableArray< T, M >

Manager for a temporary array which grows as needed.

This attempts to reduce the number of consecutive heap allocations and deallocations.

Parameters

  T | the array element type
  M | always allocate multiples of this number; must be a power of 2

Definition at line 48 of file ReusableArray.hxx.

## Constructor & Destructor Documentation

## ◆ ReusableArray() [1/2]

template<typename T, size_t M = 1>

ReusableArray< T, M >::ReusableArray | ( |  | ) |
| default

## ◆ ReusableArray() [2/2]

template<typename T, size_t M = 1>

ReusableArray< T, M >::ReusableArray | ( | ReusableArray< T, M > && | src | ) |
| inline

Definition at line 55 of file ReusableArray.hxx.

## ◆ ~ReusableArray()

template<typename T, size_t M = 1>

ReusableArray< T, M >::~ReusableArray | ( |  | ) |
| inline

Definition at line 65 of file ReusableArray.hxx.

## Member Function Documentation

## ◆ Clear()

template<typename T, size_t M = 1>

void ReusableArray< T, M >::Clear | ( |  | ) |
| inline

Free resources allocated by this object.

This invalidates the buffer returned by Get().

Definition at line 77 of file ReusableArray.hxx.

## ◆ Get()

template<typename T, size_t M = 1>

gcc_malloc T* ReusableArray< T, M >::Get | ( | size_t | size | ) |
| inline

Get the buffer, and guarantee a minimum size.

This buffer becomes invalid with the next Get() call.

Definition at line 88 of file ReusableArray.hxx.

## ◆ GetCapacity()

template<typename T, size_t M = 1>

size_t ReusableArray< T, M >::GetCapacity | ( |  | ) | const
| inline

Definition at line 69 of file ReusableArray.hxx.

## ◆ operator=()

template<typename T, size_t M = 1>

ReusableArray& ReusableArray< T, M >::operator= | ( | ReusableArray< T, M > && | src | ) |
| inline

Definition at line 59 of file ReusableArray.hxx.

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

- util/ReusableArray.hxx