Loading...
Searching...
No Matches
CopyableHeapBlock< ElementType, throwOnFailure > Class Template Reference

Wraps a HeapBlock, but additionally provides a copy constructor and remembers its size. More...

#include <juce_CopyableHeapBlock.h>

Public Member Functions

 CopyableHeapBlock ()=default
 Creates an empty block.
 
 CopyableHeapBlock (size_t numElementsIn)
 Creates a block large enough to hold the specified number of elements.
 
 CopyableHeapBlock (CopyableHeapBlock &&other) noexcept
 Moves the contents of another block into this one.
 
 CopyableHeapBlock (const CopyableHeapBlock &other)
 Copies the contents of another block into this one.
 
CopyableHeapBlockoperator= (CopyableHeapBlock &&other) noexcept
 Moves the contents of another block into this one.
 
CopyableHeapBlockoperator= (const CopyableHeapBlock &other) noexcept
 Copies the contents of another block into this one.
 
ElementType * data ()
 Returns a pointer to the first element in the block.
 
const ElementType * data () const
 Returns a pointer to the first element in the block.
 
size_t size () const
 Returns the number of elements in the block.
 
bool isEmpty () const
 Returns true if the size of the block is zero.
 
ElementType * begin ()
 Returns a pointer to the first element in the block.
 
const ElementType * begin () const
 Returns a pointer to the first element in the block.
 
const ElementType * cbegin () const
 Returns a pointer to the first element in the block.
 
ElementType * end ()
 Returns a pointer immediately after the last element in the block.
 
const ElementType * end () const
 Returns a pointer immediately after the last element in the block.
 
const ElementType * cend () const
 Returns a pointer immediately after the last element in the block.
 
ElementType & operator[] (size_t index)
 Returns a reference to the element at the provided index.
 
const ElementType & operator[] (size_t index) const
 Returns a reference to the element at the provided index.
 

Detailed Description

template<typename ElementType, bool throwOnFailure = false>
class CopyableHeapBlock< ElementType, throwOnFailure >

Wraps a HeapBlock, but additionally provides a copy constructor and remembers its size.

This class is not intended for use as a general-purpose container - in most cases, a std::vector or juce::Array is a better choice. However, CopyableHeapBlock may be handy for optimisation in situations where the container elements don't need to be value-initialised and the container doesn't need to be resized.

See also
Array, OwnedArray, MemoryBlock, HeapBlock

Constructor & Destructor Documentation

◆ CopyableHeapBlock() [1/4]

template<typename ElementType , bool throwOnFailure = false>
CopyableHeapBlock< ElementType, throwOnFailure >::CopyableHeapBlock ( )
default

Creates an empty block.

◆ CopyableHeapBlock() [2/4]

template<typename ElementType , bool throwOnFailure = false>
CopyableHeapBlock< ElementType, throwOnFailure >::CopyableHeapBlock ( size_t numElementsIn)
explicit

Creates a block large enough to hold the specified number of elements.

The contents of the block are unspecified, and must be written before they are first read.

◆ CopyableHeapBlock() [3/4]

template<typename ElementType , bool throwOnFailure = false>
CopyableHeapBlock< ElementType, throwOnFailure >::CopyableHeapBlock ( CopyableHeapBlock< ElementType, throwOnFailure > && other)
noexcept

Moves the contents of another block into this one.

◆ CopyableHeapBlock() [4/4]

template<typename ElementType , bool throwOnFailure = false>
CopyableHeapBlock< ElementType, throwOnFailure >::CopyableHeapBlock ( const CopyableHeapBlock< ElementType, throwOnFailure > & other)

Copies the contents of another block into this one.

Member Function Documentation

◆ operator=() [1/2]

template<typename ElementType , bool throwOnFailure = false>
CopyableHeapBlock & CopyableHeapBlock< ElementType, throwOnFailure >::operator= ( CopyableHeapBlock< ElementType, throwOnFailure > && other)
noexcept

Moves the contents of another block into this one.

◆ operator=() [2/2]

template<typename ElementType , bool throwOnFailure = false>
CopyableHeapBlock & CopyableHeapBlock< ElementType, throwOnFailure >::operator= ( const CopyableHeapBlock< ElementType, throwOnFailure > & other)
noexcept

Copies the contents of another block into this one.

◆ data() [1/2]

◆ data() [2/2]

template<typename ElementType , bool throwOnFailure = false>
const ElementType * CopyableHeapBlock< ElementType, throwOnFailure >::data ( ) const

Returns a pointer to the first element in the block.

◆ size()

template<typename ElementType , bool throwOnFailure = false>
size_t CopyableHeapBlock< ElementType, throwOnFailure >::size ( ) const

◆ isEmpty()

template<typename ElementType , bool throwOnFailure = false>
bool CopyableHeapBlock< ElementType, throwOnFailure >::isEmpty ( ) const

Returns true if the size of the block is zero.

References CopyableHeapBlock< ElementType, throwOnFailure >::size().

◆ begin() [1/2]

template<typename ElementType , bool throwOnFailure = false>
ElementType * CopyableHeapBlock< ElementType, throwOnFailure >::begin ( )

Returns a pointer to the first element in the block.

References CopyableHeapBlock< ElementType, throwOnFailure >::data().

◆ begin() [2/2]

template<typename ElementType , bool throwOnFailure = false>
const ElementType * CopyableHeapBlock< ElementType, throwOnFailure >::begin ( ) const

Returns a pointer to the first element in the block.

References CopyableHeapBlock< ElementType, throwOnFailure >::data().

◆ cbegin()

template<typename ElementType , bool throwOnFailure = false>
const ElementType * CopyableHeapBlock< ElementType, throwOnFailure >::cbegin ( ) const

Returns a pointer to the first element in the block.

References CopyableHeapBlock< ElementType, throwOnFailure >::data().

◆ end() [1/2]

template<typename ElementType , bool throwOnFailure = false>
ElementType * CopyableHeapBlock< ElementType, throwOnFailure >::end ( )

Returns a pointer immediately after the last element in the block.

References CopyableHeapBlock< ElementType, throwOnFailure >::data(), and CopyableHeapBlock< ElementType, throwOnFailure >::size().

◆ end() [2/2]

template<typename ElementType , bool throwOnFailure = false>
const ElementType * CopyableHeapBlock< ElementType, throwOnFailure >::end ( ) const

Returns a pointer immediately after the last element in the block.

References CopyableHeapBlock< ElementType, throwOnFailure >::data(), and CopyableHeapBlock< ElementType, throwOnFailure >::size().

◆ cend()

template<typename ElementType , bool throwOnFailure = false>
const ElementType * CopyableHeapBlock< ElementType, throwOnFailure >::cend ( ) const

Returns a pointer immediately after the last element in the block.

References CopyableHeapBlock< ElementType, throwOnFailure >::data(), and CopyableHeapBlock< ElementType, throwOnFailure >::size().

◆ operator[]() [1/2]

template<typename ElementType , bool throwOnFailure = false>
ElementType & CopyableHeapBlock< ElementType, throwOnFailure >::operator[] ( size_t index)

Returns a reference to the element at the provided index.

References CopyableHeapBlock< ElementType, throwOnFailure >::data().

◆ operator[]() [2/2]

template<typename ElementType , bool throwOnFailure = false>
const ElementType & CopyableHeapBlock< ElementType, throwOnFailure >::operator[] ( size_t index) const

Returns a reference to the element at the provided index.

References CopyableHeapBlock< ElementType, throwOnFailure >::data().


The documentation for this class was generated from the following file:
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram