ScummVM API documentation
AGS3::std::vector< T > Class Template Reference

Classes

struct  const_reverse_iterator
 
struct  reverse_iterator
 

Public Types

typedef T * iterator
 
typedef const T * const_iterator
 
typedef T value_type
 
typedef uint size_type
 

Public Member Functions

 vector (size_type count)
 
 vector (size_type count, const T &value)
 
 vector (const vector< T > &array)
 
 vector (vector< T > &&old)
 
 vector (::std::initializer_list< T > list)
 
template<class T2 >
 vector (const T2 *array, size_type n)
 
void push_back (const T &element)
 
template<class... Args>
void emplace_back (Args... args)
 
void push_back (const vector< T > &array)
 
void insert (const T &element)
 
void insert (iterator position, const_iterator first, const_iterator last)
 
void pop_back ()
 
const T * data () const
 
T * data ()
 
T & front ()
 
const T & front () const
 
T & back ()
 
const T & back () const
 
void insert_at (size_type idx, const T &element)
 
void insert_at (size_type idx, const vector< T > &array)
 
void insert (iterator pos, const T &element)
 
remove_at (size_type idx)
 
T & at (size_t index)
 
const T & at (size_t index) const
 
T & operator[] (size_type idx)
 
const T & operator[] (size_type idx) const
 
vector< T > & operator= (const vector< T > &array)
 
vectoroperator= (vector< T > &&old)
 
size_type size () const
 
void clear ()
 
iterator erase (iterator pos)
 
iterator erase (iterator first, iterator last)
 
void remove (T element)
 
bool empty () const
 
bool operator== (const vector< T > &other) const
 
bool operator!= (const vector< T > &other) const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void swap (vector &arr)
 
void rotate (iterator it)
 
const_iterator cbegin ()
 
const_iterator cend ()
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
void reserve (size_type newCapacity)
 
void resize (size_type newSize)
 
void resize (size_t newSize, const T elem)
 
void assign (const_iterator first, const_iterator last)
 

Protected Member Functions

void allocCapacity (size_type capacity)
 
void freeStorage (T *storage, const size_type elements)
 
iterator insert_aux (iterator pos, const_iterator first, const_iterator last)
 

Static Protected Member Functions

static size_type roundUpCapacity (size_type capacity)
 

Protected Attributes

size_type _capacity
 
size_type _size
 
T * _storage
 

Member Typedef Documentation

◆ iterator

template<class T>
typedef T* AGS3::std::vector< T >::iterator

vector iterator.

◆ const_iterator

template<class T>
typedef const T* AGS3::std::vector< T >::const_iterator

Const-qualified array iterator.

◆ value_type

template<class T>
typedef T AGS3::std::vector< T >::value_type

Value type of the array.

◆ size_type

template<class T>
typedef uint AGS3::std::vector< T >::size_type

Size type of the array.

Constructor & Destructor Documentation

◆ vector() [1/6]

template<class T>
AGS3::std::vector< T >::vector ( size_type  count)
inlineexplicit

Construct an array with count default-inserted instances of T. No copies are made.

◆ vector() [2/6]

template<class T>
AGS3::std::vector< T >::vector ( size_type  count,
const T &  value 
)
inline

Construct an array with count copies of elements with value value.

◆ vector() [3/6]

template<class T>
AGS3::std::vector< T >::vector ( const vector< T > &  array)
inline

Construct an array as a copy of the given array.

◆ vector() [4/6]

template<class T>
AGS3::std::vector< T >::vector ( vector< T > &&  old)
inline

Construct an array as a copy of the given array using the C++11 move semantic.

◆ vector() [5/6]

template<class T>
AGS3::std::vector< T >::vector ( ::std::initializer_list< T >  list)
inline

Construct an array using list initialization. For example:

Common::vector<int> myArray = {1, 7, 42};

constructs an array with 3 elements whose values are 1, 7, and 42 respectively.

Note
This constructor is only available when C++11 support is enabled.

◆ vector() [6/6]

template<class T>
template<class T2 >
AGS3::std::vector< T >::vector ( const T2 *  array,
size_type  n 
)
inline

Construct an array by copying data from a regular array.

Member Function Documentation

◆ push_back() [1/2]

template<class T>
void AGS3::std::vector< T >::push_back ( const T &  element)
inline

Append an element to the end of the array.

◆ push_back() [2/2]

template<class T>
void AGS3::std::vector< T >::push_back ( const vector< T > &  array)
inline

Append an element to the end of the array.

◆ insert() [1/2]

template<class T>
void AGS3::std::vector< T >::insert ( iterator  position,
const_iterator  first,
const_iterator  last 
)
inline

Adds a range of items at the specified position in the array

◆ pop_back()

template<class T>
void AGS3::std::vector< T >::pop_back ( )
inline

Remove the last element of the array.

◆ data() [1/2]

template<class T>
const T* AGS3::std::vector< T >::data ( ) const
inline

Return a pointer to the underlying memory serving as element storage.

◆ data() [2/2]

template<class T>
T* AGS3::std::vector< T >::data ( )
inline

Return a pointer to the underlying memory serving as element storage.

◆ front() [1/2]

template<class T>
T& AGS3::std::vector< T >::front ( )
inline

Return a reference to the first element of the array.

◆ front() [2/2]

template<class T>
const T& AGS3::std::vector< T >::front ( ) const
inline

Return a reference to the first element of the array.

◆ back() [1/2]

template<class T>
T& AGS3::std::vector< T >::back ( )
inline

Return a reference to the last element of the array.

◆ back() [2/2]

template<class T>
const T& AGS3::std::vector< T >::back ( ) const
inline

Return a reference to the last element of the array.

◆ insert_at() [1/2]

template<class T>
void AGS3::std::vector< T >::insert_at ( size_type  idx,
const T &  element 
)
inline

Insert an element into the array at the given position.

◆ insert_at() [2/2]

template<class T>
void AGS3::std::vector< T >::insert_at ( size_type  idx,
const vector< T > &  array 
)
inline

Insert copies of all the elements from the given array into this array at the given position.

◆ insert() [2/2]

template<class T>
void AGS3::std::vector< T >::insert ( iterator  pos,
const T &  element 
)
inline

Insert an element before pos.

◆ remove_at()

template<class T>
T AGS3::std::vector< T >::remove_at ( size_type  idx)
inline

Remove an element at the given position from the array and return the value of that element.

◆ operator[]() [1/2]

template<class T>
T& AGS3::std::vector< T >::operator[] ( size_type  idx)
inline

Return a reference to the element at the given position in the array.

◆ operator[]() [2/2]

template<class T>
const T& AGS3::std::vector< T >::operator[] ( size_type  idx) const
inline

Return a const reference to the element at the given position in the array.

◆ operator=() [1/2]

template<class T>
vector<T>& AGS3::std::vector< T >::operator= ( const vector< T > &  array)
inline

Assign the given array to this array.

◆ operator=() [2/2]

template<class T>
vector& AGS3::std::vector< T >::operator= ( vector< T > &&  old)
inline

Assign the given array to this array using the C++11 move semantic.

◆ size()

template<class T>
size_type AGS3::std::vector< T >::size ( ) const
inline

Return the size of the array.

◆ clear()

template<class T>
void AGS3::std::vector< T >::clear ( )
inline

Clear the array of all its elements.

◆ erase()

template<class T>
iterator AGS3::std::vector< T >::erase ( iterator  pos)
inline

Erase the element at pos position and return an iterator pointing to the next element in the array.

◆ remove()

template<class T>
void AGS3::std::vector< T >::remove ( element)
inline

Remove an element

◆ empty()

template<class T>
bool AGS3::std::vector< T >::empty ( ) const
inline

Check whether the array is empty.

◆ operator==()

template<class T>
bool AGS3::std::vector< T >::operator== ( const vector< T > &  other) const
inline

Check whether two arrays are identical.

◆ operator!=()

template<class T>
bool AGS3::std::vector< T >::operator!= ( const vector< T > &  other) const
inline

Check if two arrays are different.

◆ begin() [1/2]

template<class T>
iterator AGS3::std::vector< T >::begin ( )
inline

Return an iterator pointing to the first element in the array.

◆ end() [1/2]

template<class T>
iterator AGS3::std::vector< T >::end ( )
inline

Return an iterator pointing past the last element in the array.

◆ begin() [2/2]

template<class T>
const_iterator AGS3::std::vector< T >::begin ( ) const
inline

Return a const iterator pointing to the first element in the array.

◆ end() [2/2]

template<class T>
const_iterator AGS3::std::vector< T >::end ( ) const
inline

Return a const iterator pointing past the last element in the array.

◆ rotate()

template<class T>
void AGS3::std::vector< T >::rotate ( iterator  it)
inline

Rotates the array so that the item pointed to by the iterator becomes the first item, and the predeceding item becomes the last one

◆ reserve()

template<class T>
void AGS3::std::vector< T >::reserve ( size_type  newCapacity)
inline

Reserve enough memory in the array so that it can store at least the given number of elements. The current content of the array is not modified.

◆ resize()

template<class T>
void AGS3::std::vector< T >::resize ( size_type  newSize)
inline

Change the size of the array.

◆ assign()

template<class T>
void AGS3::std::vector< T >::assign ( const_iterator  first,
const_iterator  last 
)
inline

Assign to this array the elements between the given iterators from another array, from first included to last excluded.

◆ roundUpCapacity()

template<class T>
static size_type AGS3::std::vector< T >::roundUpCapacity ( size_type  capacity)
inlinestaticprotected

Round up capacity to the next power of 2. A minimal capacity of 8 is used.

◆ allocCapacity()

template<class T>
void AGS3::std::vector< T >::allocCapacity ( size_type  capacity)
inlineprotected

Allocate a specific capacity for the array.

◆ freeStorage()

template<class T>
void AGS3::std::vector< T >::freeStorage ( T *  storage,
const size_type  elements 
)
inlineprotected

Free the storage used by the array.

◆ insert_aux()

template<class T>
iterator AGS3::std::vector< T >::insert_aux ( iterator  pos,
const_iterator  first,
const_iterator  last 
)
inlineprotected

Insert a range of elements coming from this or another array. Unlike std::vector::insert, this method does not accept arbitrary iterators, mainly because our iterator system is seriously limited and does not distinguish between input iterators, output iterators, forward iterators, or random access iterators.

So, we simply restrict to vector iterators. Extending this to arbitrary random access iterators would be trivial.

Moreover, this method does not handle all cases of inserting a subrange of an array into itself; this is why it is private for now.

Member Data Documentation

◆ _capacity

template<class T>
size_type AGS3::std::vector< T >::_capacity
protected

Maximum number of elements the array can hold.

◆ _size

template<class T>
size_type AGS3::std::vector< T >::_size
protected

How many elements the array holds.

◆ _storage

template<class T>
T* AGS3::std::vector< T >::_storage
protected

Memory used for element storage.


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