Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Array< T, Allocator > Class Template Reference

#include <Array.h>

Inheritance diagram for Array< T, Allocator >:
STLAllocator< T > ByteBuffer

Public Types

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

Public Member Functions

void reserve (size_type inNewSize)
 Reserve array space. More...
 
void resize (size_type inNewSize)
 Resize array to new length. More...
 
void resize (size_type inNewSize, const T &inValue)
 Resize array to new length and initialize all elements with inValue. More...
 
void clear ()
 Destruct all elements and set length to zero. More...
 
template<class Iterator >
void assign (Iterator inBegin, Iterator inEnd)
 Replace the contents of this array with inBegin .. inEnd. More...
 
void assign (std::initializer_list< T > inList)
 Replace the contents of this array with inList. More...
 
 Array ()=default
 Default constructor. More...
 
 Array (const Allocator &inAllocator)
 Constructor with allocator. More...
 
 Array (size_type inLength, const Allocator &inAllocator={ })
 Constructor with length. More...
 
 Array (size_type inLength, const T &inValue, const Allocator &inAllocator={ })
 Constructor with length and value. More...
 
 Array (std::initializer_list< T > inList, const Allocator &inAllocator={ })
 Constructor from initializer list. More...
 
 Array (const_iterator inBegin, const_iterator inEnd, const Allocator &inAllocator={ })
 Constructor from iterator. More...
 
 Array (const Array< T, Allocator > &inRHS)
 Copy constructor. More...
 
 Array (Array< T, Allocator > &&inRHS) noexcept
 Move constructor. More...
 
 ~Array ()
 Destruct all elements. More...
 
Allocator & get_allocator ()
 Get the allocator. More...
 
const Allocator & get_allocator () const
 
void push_back (const T &inValue)
 Add element to the back of the array. More...
 
void push_back (T &&inValue)
 
template<class... A>
T & emplace_back (A &&... inValue)
 Construct element at the back of the array. More...
 
void pop_back ()
 Remove element from the back of the array. More...
 
bool empty () const
 Returns true if there are no elements in the array. More...
 
size_type size () const
 Returns amount of elements in the array. More...
 
size_type capacity () const
 Returns maximum amount of elements the array can hold. More...
 
void shrink_to_fit ()
 Reduce the capacity of the array to match its size. More...
 
void swap (Array< T, Allocator > &inRHS) noexcept
 Swap the contents of two arrays. More...
 
template<class Iterator >
void insert (const_iterator inPos, Iterator inBegin, Iterator inEnd)
 
void insert (const_iterator inPos, const T &inValue)
 
void erase (const_iterator inIter)
 Remove one element from the array. More...
 
void erase (const_iterator inBegin, const_iterator inEnd)
 Remove multiple element from the array. More...
 
const_iterator begin () const
 Iterators. More...
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
iterator begin ()
 
iterator end ()
 
const T * data () const
 
T * data ()
 
T & operator[] (size_type inIdx)
 Access element. More...
 
const T & operator[] (size_type inIdx) const
 
T & at (size_type inIdx)
 Access element. More...
 
const T & at (size_type inIdx) const
 
const T & front () const
 First element in the array. More...
 
T & front ()
 
const T & back () const
 Last element in the array. More...
 
T & back ()
 
Array< T, Allocator > & operator= (const Array< T, Allocator > &inRHS)
 Assignment operator. More...
 
Array< T, Allocator > & operator= (Array< T, Allocator > &&inRHS) noexcept
 Assignment move operator. More...
 
Array< T, Allocator > & operator= (std::initializer_list< T > inRHS)
 Assignment operator. More...
 
bool operator== (const Array< T, Allocator > &inRHS) const
 Comparing arrays. More...
 
bool operator!= (const Array< T, Allocator > &inRHS) const
 

Detailed Description

template<class T, class Allocator = STLAllocator<T>>
class Array< T, Allocator >

Simple replacement for std::vector

Major differences:

  • Memory is not initialized to zero (this was causing a lot of page faults when deserializing large MeshShapes / HeightFieldShapes)
  • Iterators are simple pointers (for now)
  • No exception safety
  • No specialization like std::vector<bool> has
  • Not all functions have been implemented

Member Typedef Documentation

◆ const_iterator

template<class T , class Allocator = STLAllocator<T>>
using Array< T, Allocator >::const_iterator = const T *

◆ const_pointer

template<class T , class Allocator = STLAllocator<T>>
using Array< T, Allocator >::const_pointer = const T *

◆ const_reference

template<class T , class Allocator = STLAllocator<T>>
using Array< T, Allocator >::const_reference = const T &

◆ iterator

template<class T , class Allocator = STLAllocator<T>>
using Array< T, Allocator >::iterator = T *

◆ pointer

template<class T , class Allocator = STLAllocator<T>>
using Array< T, Allocator >::pointer = T *

◆ reference

template<class T , class Allocator = STLAllocator<T>>
using Array< T, Allocator >::reference = T &

◆ size_type

template<class T , class Allocator = STLAllocator<T>>
using Array< T, Allocator >::size_type = size_t

◆ value_type

template<class T , class Allocator = STLAllocator<T>>
using Array< T, Allocator >::value_type = T

Constructor & Destructor Documentation

◆ Array() [1/8]

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator >::Array ( )
default

Default constructor.

◆ Array() [2/8]

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator >::Array ( const Allocator &  inAllocator)
inlineexplicit

Constructor with allocator.

◆ Array() [3/8]

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator >::Array ( size_type  inLength,
const Allocator &  inAllocator = { } 
)
inlineexplicit

Constructor with length.

◆ Array() [4/8]

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator >::Array ( size_type  inLength,
const T &  inValue,
const Allocator &  inAllocator = { } 
)
inline

Constructor with length and value.

◆ Array() [5/8]

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator >::Array ( std::initializer_list< T >  inList,
const Allocator &  inAllocator = { } 
)
inline

Constructor from initializer list.

◆ Array() [6/8]

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator >::Array ( const_iterator  inBegin,
const_iterator  inEnd,
const Allocator &  inAllocator = { } 
)
inline

Constructor from iterator.

◆ Array() [7/8]

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator >::Array ( const Array< T, Allocator > &  inRHS)
inline

Copy constructor.

◆ Array() [8/8]

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator >::Array ( Array< T, Allocator > &&  inRHS)
inlinenoexcept

Move constructor.

◆ ~Array()

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator >::~Array ( )
inline

Destruct all elements.

Member Function Documentation

◆ assign() [1/2]

template<class T , class Allocator = STLAllocator<T>>
template<class Iterator >
void Array< T, Allocator >::assign ( Iterator  inBegin,
Iterator  inEnd 
)
inline

Replace the contents of this array with inBegin .. inEnd.

◆ assign() [2/2]

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::assign ( std::initializer_list< T >  inList)
inline

Replace the contents of this array with inList.

◆ at() [1/2]

template<class T , class Allocator = STLAllocator<T>>
T & Array< T, Allocator >::at ( size_type  inIdx)
inline

Access element.

◆ at() [2/2]

template<class T , class Allocator = STLAllocator<T>>
const T & Array< T, Allocator >::at ( size_type  inIdx) const
inline

◆ back() [1/2]

template<class T , class Allocator = STLAllocator<T>>
T & Array< T, Allocator >::back ( )
inline

◆ back() [2/2]

template<class T , class Allocator = STLAllocator<T>>
const T & Array< T, Allocator >::back ( ) const
inline

Last element in the array.

◆ begin() [1/2]

template<class T , class Allocator = STLAllocator<T>>
iterator Array< T, Allocator >::begin ( )
inline

◆ begin() [2/2]

template<class T , class Allocator = STLAllocator<T>>
const_iterator Array< T, Allocator >::begin ( ) const
inline

Iterators.

◆ capacity()

template<class T , class Allocator = STLAllocator<T>>
size_type Array< T, Allocator >::capacity ( ) const
inline

Returns maximum amount of elements the array can hold.

◆ cbegin()

template<class T , class Allocator = STLAllocator<T>>
const_iterator Array< T, Allocator >::cbegin ( ) const
inline

◆ cend()

template<class T , class Allocator = STLAllocator<T>>
const_iterator Array< T, Allocator >::cend ( ) const
inline

◆ clear()

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::clear ( )
inline

Destruct all elements and set length to zero.

◆ data() [1/2]

template<class T , class Allocator = STLAllocator<T>>
T * Array< T, Allocator >::data ( )
inline

◆ data() [2/2]

template<class T , class Allocator = STLAllocator<T>>
const T * Array< T, Allocator >::data ( ) const
inline

◆ emplace_back()

template<class T , class Allocator = STLAllocator<T>>
template<class... A>
T & Array< T, Allocator >::emplace_back ( A &&...  inValue)
inline

Construct element at the back of the array.

◆ empty()

template<class T , class Allocator = STLAllocator<T>>
bool Array< T, Allocator >::empty ( ) const
inline

Returns true if there are no elements in the array.

◆ end() [1/2]

template<class T , class Allocator = STLAllocator<T>>
iterator Array< T, Allocator >::end ( )
inline

◆ end() [2/2]

template<class T , class Allocator = STLAllocator<T>>
const_iterator Array< T, Allocator >::end ( ) const
inline

◆ erase() [1/2]

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::erase ( const_iterator  inBegin,
const_iterator  inEnd 
)
inline

Remove multiple element from the array.

◆ erase() [2/2]

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::erase ( const_iterator  inIter)
inline

Remove one element from the array.

◆ front() [1/2]

template<class T , class Allocator = STLAllocator<T>>
T & Array< T, Allocator >::front ( )
inline

◆ front() [2/2]

template<class T , class Allocator = STLAllocator<T>>
const T & Array< T, Allocator >::front ( ) const
inline

First element in the array.

◆ get_allocator() [1/2]

template<class T , class Allocator = STLAllocator<T>>
Allocator & Array< T, Allocator >::get_allocator ( )
inline

Get the allocator.

◆ get_allocator() [2/2]

template<class T , class Allocator = STLAllocator<T>>
const Allocator & Array< T, Allocator >::get_allocator ( ) const
inline

◆ insert() [1/2]

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::insert ( const_iterator  inPos,
const T &  inValue 
)
inline

◆ insert() [2/2]

template<class T , class Allocator = STLAllocator<T>>
template<class Iterator >
void Array< T, Allocator >::insert ( const_iterator  inPos,
Iterator  inBegin,
Iterator  inEnd 
)
inline

◆ operator!=()

template<class T , class Allocator = STLAllocator<T>>
bool Array< T, Allocator >::operator!= ( const Array< T, Allocator > &  inRHS) const
inline

◆ operator=() [1/3]

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator > & Array< T, Allocator >::operator= ( Array< T, Allocator > &&  inRHS)
inlinenoexcept

Assignment move operator.

◆ operator=() [2/3]

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator > & Array< T, Allocator >::operator= ( const Array< T, Allocator > &  inRHS)
inline

Assignment operator.

◆ operator=() [3/3]

template<class T , class Allocator = STLAllocator<T>>
Array< T, Allocator > & Array< T, Allocator >::operator= ( std::initializer_list< T >  inRHS)
inline

Assignment operator.

◆ operator==()

template<class T , class Allocator = STLAllocator<T>>
bool Array< T, Allocator >::operator== ( const Array< T, Allocator > &  inRHS) const
inline

Comparing arrays.

◆ operator[]() [1/2]

template<class T , class Allocator = STLAllocator<T>>
T & Array< T, Allocator >::operator[] ( size_type  inIdx)
inline

Access element.

◆ operator[]() [2/2]

template<class T , class Allocator = STLAllocator<T>>
const T & Array< T, Allocator >::operator[] ( size_type  inIdx) const
inline

◆ pop_back()

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::pop_back ( )
inline

Remove element from the back of the array.

◆ push_back() [1/2]

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::push_back ( const T &  inValue)
inline

Add element to the back of the array.

◆ push_back() [2/2]

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::push_back ( T &&  inValue)
inline

◆ reserve()

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::reserve ( size_type  inNewSize)
inline

Reserve array space.

◆ resize() [1/2]

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::resize ( size_type  inNewSize)
inline

Resize array to new length.

◆ resize() [2/2]

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::resize ( size_type  inNewSize,
const T &  inValue 
)
inline

Resize array to new length and initialize all elements with inValue.

◆ shrink_to_fit()

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::shrink_to_fit ( )
inline

Reduce the capacity of the array to match its size.

◆ size()

template<class T , class Allocator = STLAllocator<T>>
size_type Array< T, Allocator >::size ( ) const
inline

Returns amount of elements in the array.

◆ swap()

template<class T , class Allocator = STLAllocator<T>>
void Array< T, Allocator >::swap ( Array< T, Allocator > &  inRHS)
inlinenoexcept

Swap the contents of two arrays.


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