Nebula
Loading...
Searching...
No Matches
Util::PinnedArray< MAX_ALLOCS, TYPE > Class Template Reference

#include <pinnedarray.h>

Inherits Util::Array< TYPE, SMALL_VECTOR_SIZE >.

Public Member Functions

 PinnedArray ()
 Default constructor.
 
 PinnedArray (const PinnedArray< MAX_ALLOCS, TYPE > &rhs)
 Construct from other pinned array.
 
 PinnedArray (SizeT capacity, SizeT grow)
 Construct from capacity and grow.
 
 PinnedArray (SizeT initialSize, SizeT grow, const TYPE &initialValue)
 Construct from initial commit size, grow and value.
 
 PinnedArray (const TYPE *const buf, SizeT num)
 Construct from pointer and size.
 
 PinnedArray (std::initializer_list< TYPE > list)
 Construct from initializer list.
 
 ~PinnedArray ()
 Destructor.
 
void operator= (const PinnedArray< MAX_ALLOCS, TYPE > &rhs)
 assignment operator
 
void operator= (PinnedArray< MAX_ALLOCS, TYPE > &&rhs) noexcept
 move operator
 
template<typename ... ELEM_TYPE>
void Append (const TYPE &first, const ELEM_TYPE &... elements)
 Append multiple elements to the end of the array.
 
void Append (const TYPE &elm)
 Append single element.
 
void Append (const TYPE &&elm)
 Append single element as rhs.
 
TYPE & Emplace ()
 Emplace element and return reference to it.
 
void Insert (IndexT index, const TYPE &elm)
 insert element before element at index
 
IndexT InsertSorted (const TYPE &elm)
 insert element into sorted array, return index where element was included
 
IndexT InsertAtEndOfIdenticalRange (IndexT startIndex, const TYPE &elm)
 insert element at the first non-identical position, return index of inclusion position
 
void AppendArray (const PinnedArray< MAX_ALLOCS, TYPE > &src)
 Append contents of another array.
 
void AppendArray (const TYPE *arr, const SizeT count)
 Append contents of C array.
 
TYPE * EmplaceArray (const SizeT count)
 Emplace an array of elements and return pointer.
 
void Fill (IndexT first, SizeT num, const TYPE &elm)
 Fill array with element.
 
void Reserve (const SizeT count)
 Reserve an amount of memory (commits to memory)
 
void Realloc (SizeT capacity, SizeT grow)
 Reallocate and clear.
 
void Resize (SizeT num)
 Resize to fit, destroys elements outside of new size.
 
void Extend (SizeT num)
 Resize to fit the provided value, but don't shrink if the new size is smaller.
 
void Free ()
 Free memory.
 
void Fit ()
 Fit array to capacity.
 
- Public Member Functions inherited from Util::Array< TYPE, SMALL_VECTOR_SIZE >
 Array ()
 constructor with default parameters
 
 Array (SizeT initialCapacity, SizeT initialGrow)
 constuctor with initial size and grow size
 
 Array (SizeT initialSize, SizeT initialGrow, const TYPE &initialValue)
 constructor with initial size, grow size and initial values
 
 Array (const ArrayT &rhs)
 copy constructor
 
 Array (ArrayT &&rhs) noexcept
 move constructor
 
 Array (std::initializer_list< TYPE > list)
 constructor from initializer list
 
 Array (std::nullptr_t)
 construct an empty fixed array
 
 Array (const TYPE *const buf, SizeT num)
 constructor from TYPE pointer and size.
 
 ~Array ()
 destructor
 
void operator= (const Array< TYPE, SMALL_VECTOR_SIZE > &rhs)
 assignment operator
 
void operator= (Array< TYPE, SMALL_VECTOR_SIZE > &&rhs) noexcept
 move operator
 
TYPE & operator[] (IndexT index) const
 [] operator
 
TYPE & operator[] (IndexT index)
 [] operator
 
bool operator== (const Array< TYPE, SMALL_VECTOR_SIZE > &rhs) const
 equality operator
 
bool operator!= (const Array< TYPE, SMALL_VECTOR_SIZE > &rhs) const
 inequality operator
 
template<typename T >
As () const
 convert to "anything"
 
TYPE & Get (IndexT index) const
 Get element (same as operator[] but as a function)
 
template<typename ... ELEM_TYPE>
void Append (const TYPE &first, const ELEM_TYPE &... elements)
 Append multiple elements to the end of the array.
 
void Append (const TYPE &elm)
 append element to end of array
 
void Append (TYPE &&elm)
 append an element which is being forwarded
 
void AppendArray (const Array< TYPE, SMALL_VECTOR_SIZE > &rhs)
 append the contents of an array to this array
 
void AppendArray (const TYPE *arr, const SizeT count)
 append from C array
 
TYPE & Emplace ()
 Emplace item (create new item and return reference)
 
TYPE * EmplaceArray (const SizeT count)
 Emplace range of items and return pointer to first.
 
void Reserve (SizeT num)
 increase capacity to fit N more elements into the array.
 
const SizeT Size () const
 get number of elements in array
 
const SizeT ByteSize () const
 return the byte size of the array.
 
const SizeT Capacity () const
 get overall allocated size of array in number of elements
 
TYPE & Front () const
 return reference to first element
 
TYPE & Back () const
 return reference to last element
 
bool IsEmpty () const
 return true if array empty
 
bool IsValidIndex (IndexT index) const
 check if index is valid
 
void EraseIndex (IndexT index)
 erase element at index, keep sorting intact
 
Iterator Erase (Iterator iter)
 erase element pointed to by iterator, keep sorting intact
 
void EraseIndexSwap (IndexT index)
 erase element at index, fill gap by swapping in last element, destroys sorting!
 
Iterator EraseSwap (Iterator iter)
 erase element at iterator, fill gap by swapping in last element, destroys sorting!
 
void EraseRange (IndexT start, IndexT end)
 erase range, excluding the element at end
 
void EraseBack ()
 erase back
 
void EraseFront ()
 erase front
 
TYPE PopFront ()
 Pop front.
 
TYPE PopBack ()
 Pop back.
 
void Insert (IndexT index, const TYPE &elm)
 insert element before element at index
 
IndexT InsertSorted (const TYPE &elm)
 insert element into sorted array, return index where element was included
 
IndexT InsertAtEndOfIdenticalRange (IndexT startIndex, const TYPE &elm)
 insert element at the first non-identical position, return index of inclusion position
 
bool IsSorted () const
 test if the array is sorted, this is a slow operation!
 
void Clear ()
 clear array (calls destructors)
 
void Reset ()
 reset array (does NOT call destructors)
 
void Free ()
 free memory and reset size
 
Iterator Begin () const
 return iterator to beginning of array
 
ConstIterator ConstBegin () const
 return const iterator to beginning of array
 
Iterator End () const
 return iterator to end of array
 
ConstIterator ConstEnd () const
 return const iterator to end of array
 
Iterator Find (const TYPE &elm, const IndexT start=0) const
 find identical element in array, return iterator
 
IndexT FindIndex (const TYPE &elm, const IndexT start=0) const
 find identical element in array, return index, InvalidIndex if not found
 
template<typename KEYTYPE >
IndexT FindIndex (typename std::enable_if< true, const KEYTYPE & >::type elm, const IndexT start=0) const
 find identical element using a specific key type
 
void Fill (IndexT first, SizeT num, const TYPE &elm)
 fill array range with element
 
void Realloc (SizeT capacity, SizeT grow)
 clear contents and preallocate with new attributes
 
ArrayT Difference (const Array< TYPE, SMALL_VECTOR_SIZE > &rhs)
 returns new array with elements which are not in rhs (slow!)
 
void Sort ()
 sort the array
 
void QuickSort ()
 quick sort the array
 
void SortWithFunc (bool(*func)(const TYPE &lhs, const TYPE &rhs))
 sort with custom function
 
void QuickSortWithFunc (int(*func)(const void *lhs, const void *rhs))
 quick sort the array
 
IndexT BinarySearchIndex (const TYPE &elm) const
 do a binary search, requires a sorted array
 
template<typename KEYTYPE >
IndexT BinarySearchIndex (typename std::enable_if< true, const KEYTYPE & >::type elm) const
 do a binary search using a specific key type
 
void Resize (SizeT num)
 Set size. Grows array if num is greater than capacity. Calls destroy on all objects at index > num!
 
template<typename ... ARGS>
void Resize (SizeT num, ARGS... args)
 Resize and fill new elements with arguments.
 
void Extend (SizeT num)
 Resize to fit the provided value, but don't shrink if the new size is smaller.
 
void Fit ()
 Fit the size of the array to the amount of elements.
 
constexpr SizeT TypeSize () const
 Returns sizeof(TYPE)
 
Iterator begin () const
 for range-based iteration
 
Iterator end () const
 
size_t size () const
 
void resize (size_t size)
 
void clear () noexcept
 
void push_back (const TYPE &item)
 
void Grow ()
 grow array with grow value
 

Private Member Functions

void Grow ()
 Grow array using growth parameter.
 
void GrowTo (SizeT newCapacity)
 Grow array by size.
 
void Delete ()
 Delete array.
 
void Copy (const PinnedArray< MAX_ALLOCS, TYPE > &src)
 Copy from array.
 
void Move (IndexT fromIndex, IndexT toIndex)
 move elements, grows array if needed
 

Additional Inherited Members

- Public Types inherited from Util::Array< TYPE, SMALL_VECTOR_SIZE >
typedef TYPE * Iterator
 define iterator
 
typedef const TYPE * ConstIterator
 
using ArrayT = Array<TYPE, SMALL_VECTOR_SIZE>
 
- Protected Member Functions inherited from Util::Array< TYPE, SMALL_VECTOR_SIZE >
void Destroy (TYPE *elm)
 destroy an element (call destructor without freeing memory)
 
void Copy (const Array< TYPE, SMALL_VECTOR_SIZE > &src)
 copy content
 
void Delete ()
 delete content
 
void GrowTo (SizeT newCapacity)
 grow array to target size
 
void Move (IndexT fromIndex, IndexT toIndex)
 move elements, grows array if needed
 
void DestroyRange (IndexT fromIndex, IndexT toIndex)
 destroy range of elements
 
void CopyRange (TYPE *to, TYPE *from, SizeT num)
 copy range
 
void MoveRange (TYPE *to, TYPE *from, SizeT num)
 move range
 
- Protected Attributes inherited from Util::Array< TYPE, SMALL_VECTOR_SIZE >
SizeT grow
 
SizeT capacity
 
SizeT count
 
TYPE * elements
 
_smallvector< TYPE, SMALL_VECTOR_SIZE > stackElements
 
- Static Protected Attributes inherited from Util::Array< TYPE, SMALL_VECTOR_SIZE >
static const SizeT MinGrowSize = 16
 
static const SizeT MaxGrowSize = 65536
 

Constructor & Destructor Documentation

◆ PinnedArray() [1/6]

template<int MAX_ALLOCS, class TYPE >
Util::PinnedArray< MAX_ALLOCS, TYPE >::PinnedArray ( )
inline

Default constructor.

◆ PinnedArray() [2/6]

template<int MAX_ALLOCS, class TYPE >
Util::PinnedArray< MAX_ALLOCS, TYPE >::PinnedArray ( const PinnedArray< MAX_ALLOCS, TYPE > & rhs)
inline

Construct from other pinned array.

◆ PinnedArray() [3/6]

template<int MAX_ALLOCS, class TYPE >
Util::PinnedArray< MAX_ALLOCS, TYPE >::PinnedArray ( SizeT capacity,
SizeT grow )
inline

Construct from capacity and grow.

◆ PinnedArray() [4/6]

template<int MAX_ALLOCS, class TYPE >
Util::PinnedArray< MAX_ALLOCS, TYPE >::PinnedArray ( SizeT initialSize,
SizeT grow,
const TYPE & initialValue )
inline

Construct from initial commit size, grow and value.

◆ PinnedArray() [5/6]

template<int MAX_ALLOCS, class TYPE >
Util::PinnedArray< MAX_ALLOCS, TYPE >::PinnedArray ( const TYPE *const buf,
SizeT num )
inline

Construct from pointer and size.

◆ PinnedArray() [6/6]

template<int MAX_ALLOCS, class TYPE >
Util::PinnedArray< MAX_ALLOCS, TYPE >::PinnedArray ( std::initializer_list< TYPE > list)
inline

Construct from initializer list.

◆ ~PinnedArray()

template<int MAX_ALLOCS, class TYPE >
Util::PinnedArray< MAX_ALLOCS, TYPE >::~PinnedArray ( )
inline

Destructor.

Member Function Documentation

◆ Append() [1/3]

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Append ( const TYPE && elm)
inline

Append single element as rhs.

◆ Append() [2/3]

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Append ( const TYPE & elm)
inline

Append single element.

◆ Append() [3/3]

template<int MAX_ALLOCS, class TYPE >
template<typename ... ELEM_TYPE>
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Append ( const TYPE & first,
const ELEM_TYPE &... elements )
inline

Append multiple elements to the end of the array.

◆ AppendArray() [1/2]

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::AppendArray ( const PinnedArray< MAX_ALLOCS, TYPE > & src)
inline

Append contents of another array.

◆ AppendArray() [2/2]

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::AppendArray ( const TYPE * arr,
const SizeT count )
inline

Append contents of C array.

◆ Copy()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Copy ( const PinnedArray< MAX_ALLOCS, TYPE > & src)
inlineprivate

Copy from array.

◆ Delete()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Delete ( )
inlineprivate

Delete array.

◆ Emplace()

template<int MAX_ALLOCS, class TYPE >
TYPE & Util::PinnedArray< MAX_ALLOCS, TYPE >::Emplace ( )
inline

Emplace element and return reference to it.

◆ EmplaceArray()

template<int MAX_ALLOCS, class TYPE >
TYPE * Util::PinnedArray< MAX_ALLOCS, TYPE >::EmplaceArray ( const SizeT count)
inline

Emplace an array of elements and return pointer.

◆ Extend()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Extend ( SizeT num)
inline

Resize to fit the provided value, but don't shrink if the new size is smaller.

◆ Fill()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Fill ( IndexT first,
SizeT num,
const TYPE & elm )
inline

Fill array with element.

◆ Fit()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Fit ( )
inline

Fit array to capacity.

◆ Free()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Free ( )
inline

Free memory.

◆ Grow()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Grow ( )
inlineprivate

Grow array using growth parameter.

◆ GrowTo()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::GrowTo ( SizeT newCapacity)
inlineprivate

Grow array by size.

◆ Insert()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Insert ( IndexT index,
const TYPE & elm )
inline

insert element before element at index

◆ InsertAtEndOfIdenticalRange()

template<int MAX_ALLOCS, class TYPE >
IndexT Util::PinnedArray< MAX_ALLOCS, TYPE >::InsertAtEndOfIdenticalRange ( IndexT startIndex,
const TYPE & elm )
inline

insert element at the first non-identical position, return index of inclusion position

◆ InsertSorted()

template<int MAX_ALLOCS, class TYPE >
IndexT Util::PinnedArray< MAX_ALLOCS, TYPE >::InsertSorted ( const TYPE & elm)
inline

insert element into sorted array, return index where element was included

◆ Move()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Move ( IndexT fromIndex,
IndexT toIndex )
inlineprivate

move elements, grows array if needed

◆ operator=() [1/2]

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::operator= ( const PinnedArray< MAX_ALLOCS, TYPE > & rhs)
inline

assignment operator

◆ operator=() [2/2]

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::operator= ( PinnedArray< MAX_ALLOCS, TYPE > && rhs)
inlinenoexcept

move operator

◆ Realloc()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Realloc ( SizeT capacity,
SizeT grow )
inline

Reallocate and clear.

◆ Reserve()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Reserve ( const SizeT count)
inline

Reserve an amount of memory (commits to memory)

◆ Resize()

template<int MAX_ALLOCS, class TYPE >
void Util::PinnedArray< MAX_ALLOCS, TYPE >::Resize ( SizeT num)
inline

Resize to fit, destroys elements outside of new size.


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