Base Framework
Public Member Functions | List of all members
ReferenceCountedAllocator< TYPE > Class Template Reference

Reference counted allocator. More...

#include <base/mem/ReferenceCountedAllocator.h>

Inherits ReferenceCountedObject, and Allocator< TYPE >.

Public Member Functions

 ReferenceCountedAllocator () noexcept
 
 ReferenceCountedAllocator (MemorySize size)
 
 ReferenceCountedAllocator (MemorySize size, MemorySize capacity)
 
 ReferenceCountedAllocator (const ReferenceCountedAllocator &copy)
 
- Public Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject () noexcept
 
 ReferenceCountedObject (const ReferenceCountedObject &copy) noexcept
 
 ReferenceCountedObject (ReferenceCountedObject &&move) noexcept
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &copy) noexcept
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&move) noexcept
 
MemorySize getNumberOfReferences_INTERNAL () const noexcept
 
virtual bool useGarbageCollector () const noexcept
 
- Public Member Functions inherited from DynamicObject
 DynamicObject () noexcept
 
bool isValidObject () const noexcept
 
virtual ~DynamicObject () noexcept(false)
 
 _COM_AZURE_DEV__BASE__OVERRIDE_ALLOC ()
 
- Public Member Functions inherited from Allocator< TYPE >
 Allocator () noexcept
 
 Allocator (MemorySize _size)
 
 Allocator (MemorySize _size, MemorySize _capacity)
 
 Allocator (const Allocator &copy)
 
 Allocator (Allocator &&move) noexcept
 
Allocatoroperator= (const Allocator &copy)
 
Allocatoroperator= (Allocator &&move) noexcept
 
TYPE * getElements () noexcept
 
const TYPE * getElements () const noexcept
 
Span< TYPE > getSpan () noexcept
 
ConstSpan< TYPE > getSpan () const noexcept
 
Iterator getBeginIterator () noexcept
 
Iterator getEndIterator () noexcept
 
ReadIterator getBeginReadIterator () const noexcept
 
ReadIterator getEndReadIterator () const noexcept
 
Iterator begin () noexcept
 
Iterator end () noexcept
 
ReadIterator begin () const noexcept
 
ReadIterator end () const noexcept
 
Enumerator getEnumerator () noexcept
 
ReadEnumerator getReadEnumerator () const noexcept
 
MemorySize getSize () const noexcept
 
MemorySize getByteSize () const noexcept
 
bool isEmpty () const noexcept
 
void ensureCapacity (MemorySize _capacity) noexcept
 
void ensureCapacity () noexcept
 
MemorySize getCapacity () const noexcept
 
void setSizeImpl (MemorySize size, const TYPE *value)
 
void setSize (MemorySize size)
 
void setSize (MemorySize size, const TYPE &value)
 
void clear ()
 
MemoryDiff garbageCollect ()
 
MemorySize getGarbageByteSize () const noexcept
 

Additional Inherited Members

- Public Types inherited from Allocator< TYPE >
typedef SequenceIterator< IteratorTraits< TYPE > > Iterator
 
typedef SequenceIterator< ReadIteratorTraits< TYPE > > ReadIterator
 
typedef AllocatorEnumerator< EnumeratorTraits< TYPE > > Enumerator
 
typedef AllocatorEnumerator< ReadEnumeratorTraits< TYPE > > ReadEnumerator
 
- Static Public Member Functions inherited from Allocator< TYPE >
static void initialize (TYPE *dest, const TYPE *end)
 
static void initialize (TYPE *dest, const TYPE *end, const TYPE &value)
 
static void initializeByCopy (TYPE *restrict dest, const TYPE *restrict src, MemorySize count)
 
static void destroy (TYPE *begin, const TYPE *_end, MemorySize &destroyedCount)
 
static void destroy2 (TYPE *begin, const TYPE *end)
 
static void initializeByMove (TYPE *dest, TYPE *src, const TYPE *end)
 
static void initializeByMove (TYPE *dest, TYPE *src, const TYPE *end, bool &moved)
 
static MemorySize align (MemorySize offset) noexcept
 
- Static Public Attributes inherited from Allocator< TYPE >
static constexpr bool useSafeDestroy = false
 
- Protected Types inherited from Allocator< TYPE >
enum  MemoryFill { INIT_MEMORY = 0xaa, DESTROY_OBJECT = 0xbb, RELEASE_MEMORY = 0xdd }
 
- Protected Member Functions inherited from Allocator< TYPE >
Span< TYPE > detach ()
 
void attach (TYPE *_buffer, MemorySize _size)
 
void attach (const Span< TYPE > &span)
 
MemorySize getAdjustedSize (MemorySize size) const noexcept
 
TYPE * allocate (const MemorySize size)
 
TYPE * resize (TYPE *buffer, const MemorySize newSize, const MemorySize originalSize)
 
bool canResizeInplace () const noexcept
 
TYPE * tryResize (TYPE *buffer, const MemorySize newSize, const MemorySize originalSize) noexcept
 
void release (TYPE *buffer, const MemorySize size)
 
- Static Protected Member Functions inherited from Allocator< TYPE >
static void fill (TYPE *dest, MemorySize size, MemoryFill memoryFill)
 

Detailed Description

template<class TYPE>
class ReferenceCountedAllocator< TYPE >

Reference counted allocator.

This class is a reference counted, low-level, and resizeable implementation of an array of elements. The implementation is not MT-safe and the class is mainly used by other container classes.

Version
1.0

Constructor & Destructor Documentation

◆ ReferenceCountedAllocator() [1/4]

template<class TYPE >
ReferenceCountedAllocator< TYPE >::ReferenceCountedAllocator ( )
inlineexplicitnoexcept

Initializes an empty allocator.

◆ ReferenceCountedAllocator() [2/4]

template<class TYPE >
ReferenceCountedAllocator< TYPE >::ReferenceCountedAllocator ( MemorySize  size)
inlineexplicit

Initializes an allocator of the specified size without initializing the elements. Raises MemoryException if unable to allocate enough memory to hold the requested number of elements.

Parameters
sizeSpecifies the initial size of the allocator.

◆ ReferenceCountedAllocator() [3/4]

template<class TYPE >
ReferenceCountedAllocator< TYPE >::ReferenceCountedAllocator ( MemorySize  size,
MemorySize  capacity 
)
inlineexplicit

Initializes an allocator of the specified size without initializing the elements. Raises MemoryException if unable to allocate enough memory to hold the requested number of elements.

Parameters
sizeSpecifies the initial size of the allocator.
capacitySpecifies the initial capacity the allocator.

◆ ReferenceCountedAllocator() [4/4]

template<class TYPE >
ReferenceCountedAllocator< TYPE >::ReferenceCountedAllocator ( const ReferenceCountedAllocator< TYPE > &  copy)
inline

Initializes the allocator by copying from the specified allocator. Raises MemoryException if unable to allocate the required memory.