Nebula
Loading...
Searching...
No Matches
Util::FixedArray< TYPE, StackAlloc > Class Template Reference

#include <fixedarray.h>

Detailed Description

template<class TYPE, bool StackAlloc = false>
class Util::FixedArray< TYPE, StackAlloc >

Implements a fixed size one-dimensional array.

Public Types

typedef TYPE * Iterator
 define element iterator

Public Member Functions

 FixedArray ()
 default constructor
 FixedArray (const SizeT s)
 constructor with size
 FixedArray (const SizeT s, const TYPE &initialValue)
 constructor with size and initial value
 FixedArray (const FixedArray< TYPE, false > &rhs)
 copy constructor
 FixedArray (const FixedArray< TYPE, true > &rhs)
 copy constructor
 FixedArray (const Array< TYPE > &rhs)
 construct from array
 FixedArray (Array< TYPE > &&rhs)
 move from array
 FixedArray (FixedArray< TYPE, StackAlloc > &&rhs)
 move constructor
 FixedArray (std::initializer_list< TYPE > list)
 constructor from initializer list
 FixedArray (std::nullptr_t)
 construct an empty fixed array
 ~FixedArray ()
 destructor
void operator= (const FixedArray< TYPE, StackAlloc > &rhs)
 assignment operator
void operator= (FixedArray< TYPE, StackAlloc > &&rhs) noexcept
 move assignment operator
TYPE & operator[] (IndexT index) const
 write [] operator
bool operator== (const FixedArray< TYPE, StackAlloc > &rhs) const
 equality operator
bool operator!= (const FixedArray< TYPE, StackAlloc > &rhs) const
 inequality operator
void SetSize (SizeT s)
 set number of elements (clears existing content)
const SizeT Size () const
 get number of elements
const SizeT ByteSize () const
 get total byte size
void Resize (SizeT newSize)
 resize array without deleting existing content
bool IsEmpty () const
 return true if array if empty (has no elements)
void Clear ()
 clear the array, free elements
void Reset ()
 Reset the size and destroy all elements.
void Fill (const TYPE &val)
 fill the entire array with a value
void Fill (IndexT first, SizeT num, const TYPE &val)
 fill array range with element
Iterator Begin () const
 get iterator to first element
Iterator End () const
 get iterator past last element
TYPE & Front () const
 return reference to first element
TYPE & Back () const
 return reference to last element
Iterator Find (const TYPE &val) const
 find identical element in unsorted array (slow)
IndexT FindIndex (const TYPE &val) const
 find index of identical element in unsorted array (slow)
void Sort ()
 sort the array
IndexT BinarySearchIndex (const TYPE &val) const
 do a binary search, requires a sorted array
Array< TYPE > AsArray () const
 return content as Array (slow!)
Iterator begin () const
 for range-based iteration (C++11)
Iterator end () const
size_t size () const
void resize (size_t size)

Private Member Functions

void Delete ()
 delete content
void Alloc (SizeT s)
 allocate array for given size
void Copy (const FixedArray< TYPE, StackAlloc > &src)
 copy content

Private Attributes

SizeT count
TYPE * elements

Friends

template<class T, bool S>
class FixedArray

Member Typedef Documentation

◆ Iterator

template<class TYPE, bool StackAlloc = false>
typedef TYPE* Util::FixedArray< TYPE, StackAlloc >::Iterator

define element iterator

Constructor & Destructor Documentation

◆ FixedArray() [1/10]

template<class TYPE, bool StackAlloc>
Util::FixedArray< TYPE, StackAlloc >::FixedArray ( )

default constructor

◆ FixedArray() [2/10]

template<class TYPE, bool StackAlloc>
Util::FixedArray< TYPE, StackAlloc >::FixedArray ( const SizeT s)

constructor with size

◆ FixedArray() [3/10]

template<class TYPE, bool StackAlloc>
Util::FixedArray< TYPE, StackAlloc >::FixedArray ( const SizeT s,
const TYPE & initialValue )

constructor with size and initial value

◆ FixedArray() [4/10]

template<class TYPE, bool StackAlloc>
Util::FixedArray< TYPE, StackAlloc >::FixedArray ( const FixedArray< TYPE, false > & rhs)

copy constructor

◆ FixedArray() [5/10]

template<class TYPE, bool StackAlloc>
Util::FixedArray< TYPE, StackAlloc >::FixedArray ( const FixedArray< TYPE, true > & rhs)

copy constructor

◆ FixedArray() [6/10]

template<class TYPE, bool StackAlloc>
Util::FixedArray< TYPE, StackAlloc >::FixedArray ( const Array< TYPE > & rhs)

construct from array

◆ FixedArray() [7/10]

template<class TYPE, bool StackAlloc>
Util::FixedArray< TYPE, StackAlloc >::FixedArray ( Array< TYPE > && rhs)

move from array

◆ FixedArray() [8/10]

template<class TYPE, bool StackAlloc>
Util::FixedArray< TYPE, StackAlloc >::FixedArray ( FixedArray< TYPE, StackAlloc > && rhs)

move constructor

◆ FixedArray() [9/10]

template<class TYPE, bool StackAlloc>
Util::FixedArray< TYPE, StackAlloc >::FixedArray ( std::initializer_list< TYPE > list)

constructor from initializer list

◆ FixedArray() [10/10]

template<class TYPE, bool StackAlloc>
Util::FixedArray< TYPE, StackAlloc >::FixedArray ( std::nullptr_t )

construct an empty fixed array

◆ ~FixedArray()

template<class TYPE, bool StackAlloc>
Util::FixedArray< TYPE, StackAlloc >::~FixedArray ( )

destructor

Member Function Documentation

◆ Alloc()

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::Alloc ( SizeT s)
private

allocate array for given size

◆ AsArray()

template<class TYPE, bool StackAlloc>
Array< TYPE > Util::FixedArray< TYPE, StackAlloc >::AsArray ( ) const

return content as Array (slow!)

◆ Back()

template<class TYPE, bool StackAlloc>
TYPE & Util::FixedArray< TYPE, StackAlloc >::Back ( ) const
inline

return reference to last element

◆ Begin()

template<class TYPE, bool StackAlloc>
FixedArray< TYPE, StackAlloc >::Iterator Util::FixedArray< TYPE, StackAlloc >::Begin ( ) const

get iterator to first element

◆ begin()

template<class TYPE, bool StackAlloc>
FixedArray< TYPE, StackAlloc >::Iterator Util::FixedArray< TYPE, StackAlloc >::begin ( ) const

for range-based iteration (C++11)

◆ BinarySearchIndex()

template<class TYPE, bool StackAlloc>
IndexT Util::FixedArray< TYPE, StackAlloc >::BinarySearchIndex ( const TYPE & elm) const

do a binary search, requires a sorted array

Todo
hmm, this is copy-pasted from Array...

◆ ByteSize()

template<class TYPE, bool StackAlloc>
const SizeT Util::FixedArray< TYPE, StackAlloc >::ByteSize ( ) const

get total byte size

◆ Clear()

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::Clear ( )

clear the array, free elements

◆ Copy()

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::Copy ( const FixedArray< TYPE, StackAlloc > & rhs)
private

copy content

NOTE: only works on deleted array.

This is intended.

◆ Delete()

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::Delete ( )
private

delete content

◆ End()

template<class TYPE, bool StackAlloc>
FixedArray< TYPE, StackAlloc >::Iterator Util::FixedArray< TYPE, StackAlloc >::End ( ) const

get iterator past last element

◆ end()

template<class TYPE, bool StackAlloc>
FixedArray< TYPE, StackAlloc >::Iterator Util::FixedArray< TYPE, StackAlloc >::end ( ) const

◆ Fill() [1/2]

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::Fill ( const TYPE & val)

fill the entire array with a value

◆ Fill() [2/2]

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::Fill ( IndexT first,
SizeT num,
const TYPE & val )

fill array range with element

◆ Find()

template<class TYPE, bool StackAlloc>
FixedArray< TYPE, StackAlloc >::Iterator Util::FixedArray< TYPE, StackAlloc >::Find ( const TYPE & val) const

find identical element in unsorted array (slow)

◆ FindIndex()

template<class TYPE, bool StackAlloc>
IndexT Util::FixedArray< TYPE, StackAlloc >::FindIndex ( const TYPE & val) const

find index of identical element in unsorted array (slow)

◆ Front()

template<class TYPE, bool StackAlloc>
TYPE & Util::FixedArray< TYPE, StackAlloc >::Front ( ) const
inline

return reference to first element

◆ IsEmpty()

template<class TYPE, bool StackAlloc>
bool Util::FixedArray< TYPE, StackAlloc >::IsEmpty ( ) const

return true if array if empty (has no elements)

◆ operator!=()

template<class TYPE, bool StackAlloc>
bool Util::FixedArray< TYPE, StackAlloc >::operator!= ( const FixedArray< TYPE, StackAlloc > & rhs) const

inequality operator

◆ operator=() [1/2]

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::operator= ( const FixedArray< TYPE, StackAlloc > & rhs)

assignment operator

◆ operator=() [2/2]

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::operator= ( FixedArray< TYPE, StackAlloc > && rhs)
noexcept

move assignment operator

◆ operator==()

template<class TYPE, bool StackAlloc>
bool Util::FixedArray< TYPE, StackAlloc >::operator== ( const FixedArray< TYPE, StackAlloc > & rhs) const

equality operator

◆ operator[]()

template<class TYPE, bool StackAlloc>
TYPE & Util::FixedArray< TYPE, StackAlloc >::operator[] ( IndexT index) const

write [] operator

◆ Reset()

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::Reset ( )
inline

Reset the size and destroy all elements.

◆ Resize()

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::Resize ( SizeT newSize)

resize array without deleting existing content

◆ resize()

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::resize ( size_t size)

◆ SetSize()

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::SetSize ( SizeT s)

set number of elements (clears existing content)

◆ Size()

template<class TYPE, bool StackAlloc>
const SizeT Util::FixedArray< TYPE, StackAlloc >::Size ( ) const

get number of elements

◆ size()

template<class TYPE, bool StackAlloc>
size_t Util::FixedArray< TYPE, StackAlloc >::size ( ) const

◆ Sort()

template<class TYPE, bool StackAlloc>
void Util::FixedArray< TYPE, StackAlloc >::Sort ( )

sort the array

◆ FixedArray

template<class TYPE, bool StackAlloc = false>
template<class T, bool S>
friend class FixedArray
friend

Member Data Documentation

◆ count

template<class TYPE, bool StackAlloc = false>
SizeT Util::FixedArray< TYPE, StackAlloc >::count
private

◆ elements

template<class TYPE, bool StackAlloc = false>
TYPE* Util::FixedArray< TYPE, StackAlloc >::elements
private

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