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

#include <fixedarray.h>

Detailed Description

template<class TYPE>
class Util::FixedArray< TYPE >

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 > &rhs)
 copy constructor
 
 FixedArray (const Array< TYPE > &rhs)
 construct from array
 
 FixedArray (FixedArray< TYPE > &&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 > &rhs)
 assignment operator
 
void operator= (FixedArray< TYPE > &&rhs) noexcept
 move assignment operator
 
TYPE & operator[] (IndexT index) const
 write [] operator
 
bool operator== (const FixedArray< TYPE > &rhs) const
 equality operator
 
bool operator!= (const FixedArray< TYPE > &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 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
 
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 > &src)
 copy content
 

Private Attributes

SizeT count
 
TYPE * elements
 

Member Typedef Documentation

◆ Iterator

template<class TYPE >
typedef TYPE* Util::FixedArray< TYPE >::Iterator

define element iterator

Constructor & Destructor Documentation

◆ FixedArray() [1/8]

template<class TYPE >
Util::FixedArray< TYPE >::FixedArray ( )

default constructor

◆ FixedArray() [2/8]

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

constructor with size

◆ FixedArray() [3/8]

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

constructor with size and initial value

◆ FixedArray() [4/8]

template<class TYPE >
Util::FixedArray< TYPE >::FixedArray ( const FixedArray< TYPE > & rhs)

copy constructor

◆ FixedArray() [5/8]

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

construct from array

◆ FixedArray() [6/8]

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

move constructor

◆ FixedArray() [7/8]

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

constructor from initializer list

◆ FixedArray() [8/8]

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

construct an empty fixed array

◆ ~FixedArray()

template<class TYPE >
Util::FixedArray< TYPE >::~FixedArray ( )

destructor

Member Function Documentation

◆ Alloc()

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

allocate array for given size

◆ AsArray()

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

return content as Array (slow!)

◆ Begin()

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

get iterator to first element

◆ begin()

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

for range-based iteration (C++11)

◆ BinarySearchIndex()

template<class TYPE >
IndexT Util::FixedArray< TYPE >::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 >
const SizeT Util::FixedArray< TYPE >::ByteSize ( ) const

get total byte size

◆ Clear()

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

clear the array, free elements

◆ Copy()

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

copy content

NOTE: only works on deleted array.

This is intended.

◆ Delete()

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

delete content

◆ End()

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

get iterator past last element

◆ end()

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

◆ Fill() [1/2]

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

fill the entire array with a value

◆ Fill() [2/2]

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

fill array range with element

◆ Find()

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

find identical element in unsorted array (slow)

◆ FindIndex()

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

find index of identical element in unsorted array (slow)

◆ IsEmpty()

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

return true if array if empty (has no elements)

◆ operator!=()

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

inequality operator

◆ operator=() [1/2]

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

assignment operator

◆ operator=() [2/2]

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

move assignment operator

◆ operator==()

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

equality operator

◆ operator[]()

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

write [] operator

◆ resize()

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

◆ Resize()

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

resize array without deleting existing content

◆ SetSize()

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

set number of elements (clears existing content)

◆ Size()

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

get number of elements

◆ size()

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

◆ Sort()

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

sort the array

Member Data Documentation

◆ count

template<class TYPE >
SizeT Util::FixedArray< TYPE >::count
private

◆ elements

template<class TYPE >
TYPE* Util::FixedArray< TYPE >::elements
private

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