Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
cLazyArray< T > Class Template Reference

A dynamic array that defers allocation to the first modifying access. More...

#include <LazyArray.h>

Public Types

using const_iterator = const_pointer
 
using const_pointer = const T *
 
using const_reference = const T &
 
using iterator = pointer
 
using pointer = T *
 
using reference = T &
 
using size_type = int
 
using value_type = T
 

Public Member Functions

iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
 cLazyArray (cLazyArray &&a_Other) noexcept
 
 cLazyArray (const cLazyArray &a_Other)
 
 cLazyArray (size_type a_Size) noexcept
 
T * data ()
 
const T * data () const
 
iterator end ()
 
const_iterator end () const
 
const T & GetAt (size_type a_Idx) const
 A const view of an element of the array. More...
 
bool IsStorageAllocated () const noexcept
 Returns true if the array has already been allocated. More...
 
cLazyArrayoperator= (cLazyArray &&a_Other) noexcept
 
cLazyArrayoperator= (const cLazyArray &a_Other)
 
T & operator[] (size_type a_Idx)
 
const T & operator[] (size_type a_Idx) const
 
size_type size () const noexcept
 
void swap (cLazyArray &a_Other) noexcept
 

Private Attributes

std::unique_ptr< T[]> m_Array
 
size_type m_Size
 

Friends

void swap (cLazyArray &a_Lhs, cLazyArray &a_Rhs) noexcept
 

Detailed Description

template<typename T>
class cLazyArray< T >

A dynamic array that defers allocation to the first modifying access.

Const references from the array before allocation will all be to the same default constructed value. It is therefore important that default constructed values are indistinguishable from each other.

Definition at line 8 of file LazyArray.h.

Member Typedef Documentation

◆ const_iterator

template<typename T >
using cLazyArray< T >::const_iterator = const_pointer

Definition at line 22 of file LazyArray.h.

◆ const_pointer

template<typename T >
using cLazyArray< T >::const_pointer = const T *

Definition at line 17 of file LazyArray.h.

◆ const_reference

template<typename T >
using cLazyArray< T >::const_reference = const T &

Definition at line 19 of file LazyArray.h.

◆ iterator

template<typename T >
using cLazyArray< T >::iterator = pointer

Definition at line 21 of file LazyArray.h.

◆ pointer

template<typename T >
using cLazyArray< T >::pointer = T *

Definition at line 16 of file LazyArray.h.

◆ reference

template<typename T >
using cLazyArray< T >::reference = T &

Definition at line 18 of file LazyArray.h.

◆ size_type

template<typename T >
using cLazyArray< T >::size_type = int

Definition at line 20 of file LazyArray.h.

◆ value_type

template<typename T >
using cLazyArray< T >::value_type = T

Definition at line 15 of file LazyArray.h.

Constructor & Destructor Documentation

◆ cLazyArray() [1/3]

template<typename T >
cLazyArray< T >::cLazyArray ( size_type  a_Size)
inlinenoexcept

Definition at line 24 of file LazyArray.h.

◆ cLazyArray() [2/3]

template<typename T >
cLazyArray< T >::cLazyArray ( const cLazyArray< T > &  a_Other)
inline

Definition at line 30 of file LazyArray.h.

◆ cLazyArray() [3/3]

template<typename T >
cLazyArray< T >::cLazyArray ( cLazyArray< T > &&  a_Other)
inlinenoexcept

Definition at line 40 of file LazyArray.h.

Member Function Documentation

◆ begin() [1/2]

template<typename T >
iterator cLazyArray< T >::begin ( )
inline

Definition at line 73 of file LazyArray.h.

◆ begin() [2/2]

template<typename T >
const_iterator cLazyArray< T >::begin ( ) const
inline

Definition at line 74 of file LazyArray.h.

◆ cbegin()

template<typename T >
const_iterator cLazyArray< T >::cbegin ( ) const
inline

Definition at line 72 of file LazyArray.h.

◆ cend()

template<typename T >
const_iterator cLazyArray< T >::cend ( ) const
inline

Definition at line 76 of file LazyArray.h.

◆ data() [1/2]

template<typename T >
T* cLazyArray< T >::data ( )
inline

Definition at line 91 of file LazyArray.h.

◆ data() [2/2]

template<typename T >
const T* cLazyArray< T >::data ( ) const
inline

Definition at line 82 of file LazyArray.h.

◆ end() [1/2]

template<typename T >
iterator cLazyArray< T >::end ( )
inline

Definition at line 77 of file LazyArray.h.

◆ end() [2/2]

template<typename T >
const_iterator cLazyArray< T >::end ( ) const
inline

Definition at line 78 of file LazyArray.h.

◆ GetAt()

template<typename T >
const T& cLazyArray< T >::GetAt ( size_type  a_Idx) const
inline

A const view of an element of the array.

Never causes the array to allocate.

Definition at line 112 of file LazyArray.h.

◆ IsStorageAllocated()

template<typename T >
bool cLazyArray< T >::IsStorageAllocated ( ) const
inlinenoexcept

Returns true if the array has already been allocated.

Definition at line 127 of file LazyArray.h.

◆ operator=() [1/2]

template<typename T >
cLazyArray& cLazyArray< T >::operator= ( cLazyArray< T > &&  a_Other)
inlinenoexcept

Definition at line 52 of file LazyArray.h.

◆ operator=() [2/2]

template<typename T >
cLazyArray& cLazyArray< T >::operator= ( const cLazyArray< T > &  a_Other)
inline

Definition at line 46 of file LazyArray.h.

◆ operator[]() [1/2]

template<typename T >
T& cLazyArray< T >::operator[] ( size_type  a_Idx)
inline

Definition at line 59 of file LazyArray.h.

◆ operator[]() [2/2]

template<typename T >
const T& cLazyArray< T >::operator[] ( size_type  a_Idx) const
inline

Definition at line 65 of file LazyArray.h.

◆ size()

template<typename T >
size_type cLazyArray< T >::size ( ) const
inlinenoexcept

Definition at line 80 of file LazyArray.h.

◆ swap()

template<typename T >
void cLazyArray< T >::swap ( cLazyArray< T > &  a_Other)
inlinenoexcept

Definition at line 98 of file LazyArray.h.

Friends And Related Function Documentation

◆ swap

template<typename T >
void swap ( cLazyArray< T > &  a_Lhs,
cLazyArray< T > &  a_Rhs 
)
friend

Definition at line 104 of file LazyArray.h.

Member Data Documentation

◆ m_Array

template<typename T >
std::unique_ptr<T[]> cLazyArray< T >::m_Array
mutableprivate

Definition at line 131 of file LazyArray.h.

◆ m_Size

template<typename T >
size_type cLazyArray< T >::m_Size
private

Definition at line 132 of file LazyArray.h.


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