ufe 7.0
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
Ufe::Array< T > Class Template Reference

Array is a container class that encapsulates dynamic sized arrays. More...

#include <array.h>

Public Types

typedef T value_type
 
typedef T & reference
 
typedef const T & const_reference
 
typedef T * pointer
 
typedef const T * const_pointer
 
using iterator = T *
 
using const_iterator = const T *
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
using size_type = std::size_t
 

Public Member Functions

Constructors and Destructor
 Array ()
 Default constructor. Creates an empty Array. More...
 
 Array (const Array &)
 Copy constructor. More...
 
 Array (size_type count)
 Constructs an array with count default-inserted objects of T. More...
 
 Array (size_type count, const value_type &value)
 Constructs an array with count copies of elements with value value. More...
 
 Array (std::initializer_list< value_type > il)
 Initializer list constructor. More...
 
template<typename InputIt >
 Array (InputIt first, InputIt last)
 Range constructor. Creates a Array with elements from the range [first, last). More...
 
 Array (Array &&) noexcept
 Move constructor. More...
 
 ~Array ()
 Destructor. More...
 
Assignment Operators
Arrayoperator= (const Array &other)
 Copy assignment operator. More...
 
Arrayoperator= (Array &&other) noexcept
 Move assignment operator. More...
 
Arrayoperator= (std::initializer_list< value_type > il)
 Initializer list assignment operator. More...
 
Iterators
iterator begin ()
 Returns an iterator to the first element of the array. More...
 
const_iterator begin () const
 Returns a constant iterator to the first element of the array. More...
 
const_iterator cbegin () const
 Returns a constant iterator to the first element of the array. More...
 
iterator end ()
 Returns an iterator to the element following the last element of the array. More...
 
const_iterator end () const
 Returns a constant iterator to the element following the last element of the array. More...
 
const_iterator cend () const
 Returns a constant iterator to the element following the last element of the array. More...
 
reverse_iterator rbegin ()
 Returns a reverse iterator to the end of the array. More...
 
const_reverse_iterator rbegin () const
 Returns a constant reverse iterator to the end of the array. More...
 
const_reverse_iterator crbegin () const
 Returns a constant reverse iterator to the end of the array. More...
 
reverse_iterator rend ()
 Returns a reverse iterator to the beginning of the array. More...
 
const_reverse_iterator rend () const
 Returns a constant reverse iterator to the beginning of the array. More...
 
const_reverse_iterator crend () const
 Returns a constant reverse iterator to the beginning of the array. More...
 
Capacity
size_type size () const
 Returns the number of elements in the container. More...
 
size_type capacity () const
 Returns the number of elements that can be held in currently allocated storage. More...
 
bool empty () const
 Checks if the array has no elements. More...
 
void reserve (size_type n)
 Requests that the capacity be at least enough to contain n elements. More...
 
Element access
reference operator[] (size_type n)
 Returns a reference to the element at specified location n. More...
 
const_reference operator[] (size_type n) const
 Returns a constant reference to the element at specified location n. More...
 
reference at (size_type n)
 Returns a reference to the element at specified location pos, with bounds checking. More...
 
const_reference at (size_type n) const
 Returns a constant reference to the element at specified location pos, with bounds checking. More...
 
reference front ()
 Returns a reference to the first element in the array. More...
 
const_reference front () const
 Returns a constant reference to the first element in the array. More...
 
reference back ()
 Returns a reference to the last element in the array. More...
 
const_reference back () const
 Returns a constant reference to the last element in the array. More...
 
value_typedata ()
 Returns a pointer to this array's data. More...
 
const value_typedata () const
 Returns a const pointer to this array's data. More...
 
Modifiers
void assign (size_type n, const value_type &val)
 Replaces the contents with n copies of val. More...
 
template<typename InputIt >
void assign (InputIt first, InputIt last)
 Replaces the contents with copies of the elements in the range [first, last). More...
 
void assign (std::initializer_list< value_type > il)
 Replaces the contents with copies of the elements in the initializer list il. More...
 
void push_back (const value_type &val)
 Appends an element to the end of the array. More...
 
void push_back (value_type &&val)
 Appends an element to the end of the array. More...
 
void pop_back ()
 Removes the last element of the array. More...
 
iterator insert (const_iterator position, const value_type &val)
 Inserts a copy of val before the element at the specified position position. More...
 
iterator insert (const_iterator position, value_type &&val)
 Inserts val before the element at the specified position position possibly moving it. More...
 
iterator insert (const_iterator position, size_type n, const value_type &val)
 Inserts n copies of val before the element at the specified position position. More...
 
template<class InputIt >
std::enable_if_t<!std::is_integral_v< InputIt >, iteratorinsert (const_iterator position, InputIt first, InputIt last)
 Inserts copies of the elements in the range [first, last) before the element at the specified position position. More...
 
iterator insert (const_iterator position, std::initializer_list< value_type > il)
 Inserts copies of the elements in the initializer list il before the element at the specified position position. More...
 
iterator erase (iterator position)
 Removes the element at the specified position position. More...
 
iterator erase (const_iterator position)
 Removes the element at the specified position position. More...
 
iterator erase (iterator first, iterator last)
 Removes the elements in the range [first, last). More...
 
iterator erase (const_iterator first, const_iterator last)
 Removes the elements in the range [first, last). More...
 
void swap (Array &other)
 Exchanges the contents and capacity of the array with those of other. More...
 
void resize (size_type count)
 Resizes the array to contain count elements. More...
 
void resize (size_type count, const value_type &value)
 Resizes the array to contain count elements. More...
 
void clear ()
 Removes all elements from the array. The array will be empty after this call. More...
 
template<typename... Args>
iterator emplace (const_iterator position, Args &&... args)
 Constructs a new element in-place at the specified position position. More...
 
template<typename... Args>
void emplace_back (Args &&... args)
 Constructs a new element in-place at the end of the array. More...
 
Comparison Operators
bool operator== (const Array &other) const
 
bool operator!= (const Array &other) const
 
bool operator< (const Array &other) const
 
bool operator<= (const Array &other) const
 
bool operator> (const Array &other) const
 
bool operator>= (const Array &other) const
 

Private Attributes

std::unique_ptr< Imp > _imp
 

Detailed Description

template<typename T>
class Ufe::Array< T >

Array is a container class that encapsulates dynamic sized arrays.

Arrays use contiguous storage locations for their elements, which means that their elements can also be accessed using offsets on regular pointers to its elements. Their size can change dynamically, with their storage being handled automatically by the container.

Array is a template class that wraps std::vector functionality using the PIMPL (Pointer to Implementation) idiom. All operations are forwarded to the hidden internal implementation.

This class is instantiated for the following types:

Definition at line 64 of file array.h.

Member Typedef Documentation

◆ const_iterator

template<typename T >
using Ufe::Array< T >::const_iterator = const T*

Definition at line 76 of file array.h.

◆ const_pointer

template<typename T >
typedef const T* Ufe::Array< T >::const_pointer

Definition at line 72 of file array.h.

◆ const_reference

template<typename T >
typedef const T& Ufe::Array< T >::const_reference

Definition at line 70 of file array.h.

◆ const_reverse_iterator

template<typename T >
typedef std::reverse_iterator<const_iterator> Ufe::Array< T >::const_reverse_iterator

Definition at line 78 of file array.h.

◆ iterator

template<typename T >
using Ufe::Array< T >::iterator = T*

Definition at line 75 of file array.h.

◆ pointer

template<typename T >
typedef T* Ufe::Array< T >::pointer

Definition at line 71 of file array.h.

◆ reference

template<typename T >
typedef T& Ufe::Array< T >::reference

Definition at line 69 of file array.h.

◆ reverse_iterator

template<typename T >
typedef std::reverse_iterator<iterator> Ufe::Array< T >::reverse_iterator

Definition at line 77 of file array.h.

◆ size_type

template<typename T >
using Ufe::Array< T >::size_type = std::size_t

Definition at line 80 of file array.h.

◆ value_type

template<typename T >
typedef T Ufe::Array< T >::value_type

Definition at line 68 of file array.h.

Constructor & Destructor Documentation

◆ Array() [1/7]

template<typename T >
Ufe::Array< T >::Array ( )

Default constructor. Creates an empty Array.

◆ Array() [2/7]

template<typename T >
Ufe::Array< T >::Array ( const Array< T > &  )

Copy constructor.

◆ Array() [3/7]

template<typename T >
Ufe::Array< T >::Array ( size_type  count)
explicit

Constructs an array with count default-inserted objects of T.

◆ Array() [4/7]

template<typename T >
Ufe::Array< T >::Array ( size_type  count,
const value_type value 
)
explicit

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

◆ Array() [5/7]

template<typename T >
Ufe::Array< T >::Array ( std::initializer_list< value_type il)

Initializer list constructor.

◆ Array() [6/7]

template<typename T >
template<typename InputIt >
Ufe::Array< T >::Array ( InputIt  first,
InputIt  last 
)
inline

Range constructor. Creates a Array with elements from the range [first, last).

Definition at line 103 of file array.h.

◆ Array() [7/7]

template<typename T >
Ufe::Array< T >::Array ( Array< T > &&  )
noexcept

Move constructor.

Note
Right hand side becomes invalid object and can no longer be used in the current state. You can call clear() to reset it to an empty state.

◆ ~Array()

template<typename T >
Ufe::Array< T >::~Array ( )

Destructor.

Member Function Documentation

◆ assign() [1/3]

template<typename T >
template<typename InputIt >
void Ufe::Array< T >::assign ( InputIt  first,
InputIt  last 
)
inline

Replaces the contents with copies of the elements in the range [first, last).

Definition at line 259 of file array.h.

◆ assign() [2/3]

template<typename T >
void Ufe::Array< T >::assign ( size_type  n,
const value_type val 
)

Replaces the contents with n copies of val.

◆ assign() [3/3]

template<typename T >
void Ufe::Array< T >::assign ( std::initializer_list< value_type il)

Replaces the contents with copies of the elements in the initializer list il.

◆ at() [1/2]

template<typename T >
reference Ufe::Array< T >::at ( size_type  n)

Returns a reference to the element at specified location pos, with bounds checking.

Exceptions
std::out_of_rangeIf pos is not within the range of the array.
Parameters
[in]nPosition of the element to return.
Returns
A reference to the requested element.

◆ at() [2/2]

template<typename T >
const_reference Ufe::Array< T >::at ( size_type  n) const

Returns a constant reference to the element at specified location pos, with bounds checking.

Exceptions
std::out_of_rangeIf pos is not within the range of the array.
Parameters
[in]nPosition of the element to return.
Returns
A constant reference to the requested element.

◆ back() [1/2]

template<typename T >
reference Ufe::Array< T >::back ( )

Returns a reference to the last element in the array.

Note
Invokes undefined behavior if the array is empty.
Returns
A reference to the last element.

◆ back() [2/2]

template<typename T >
const_reference Ufe::Array< T >::back ( ) const

Returns a constant reference to the last element in the array.

Note
Invokes undefined behavior if the array is empty.
Returns
A constant reference to the last element.

◆ begin() [1/2]

template<typename T >
iterator Ufe::Array< T >::begin ( )

Returns an iterator to the first element of the array.

◆ begin() [2/2]

template<typename T >
const_iterator Ufe::Array< T >::begin ( ) const

Returns a constant iterator to the first element of the array.

◆ capacity()

template<typename T >
size_type Ufe::Array< T >::capacity ( ) const

Returns the number of elements that can be held in currently allocated storage.

◆ cbegin()

template<typename T >
const_iterator Ufe::Array< T >::cbegin ( ) const
inline

Returns a constant iterator to the first element of the array.

Definition at line 145 of file array.h.

◆ cend()

template<typename T >
const_iterator Ufe::Array< T >::cend ( ) const
inline

Returns a constant iterator to the element following the last element of the array.

Definition at line 154 of file array.h.

◆ clear()

template<typename T >
void Ufe::Array< T >::clear ( )

Removes all elements from the array. The array will be empty after this call.

◆ crbegin()

template<typename T >
const_reverse_iterator Ufe::Array< T >::crbegin ( ) const
inline

Returns a constant reverse iterator to the end of the array.

Definition at line 163 of file array.h.

◆ crend()

template<typename T >
const_reverse_iterator Ufe::Array< T >::crend ( ) const
inline

Returns a constant reverse iterator to the beginning of the array.

Definition at line 172 of file array.h.

◆ data() [1/2]

template<typename T >
value_type * Ufe::Array< T >::data ( )

Returns a pointer to this array's data.

◆ data() [2/2]

template<typename T >
const value_type * Ufe::Array< T >::data ( ) const

Returns a const pointer to this array's data.

◆ emplace()

template<typename T >
template<typename... Args>
iterator Ufe::Array< T >::emplace ( const_iterator  position,
Args &&...  args 
)

Constructs a new element in-place at the specified position position.

Returns
An iterator pointing to the newly constructed element.

◆ emplace_back()

template<typename T >
template<typename... Args>
void Ufe::Array< T >::emplace_back ( Args &&...  args)

Constructs a new element in-place at the end of the array.

◆ empty()

template<typename T >
bool Ufe::Array< T >::empty ( ) const

Checks if the array has no elements.

Returns
true if the array is empty, false otherwise.

◆ end() [1/2]

template<typename T >
iterator Ufe::Array< T >::end ( )

Returns an iterator to the element following the last element of the array.

◆ end() [2/2]

template<typename T >
const_iterator Ufe::Array< T >::end ( ) const

Returns a constant iterator to the element following the last element of the array.

◆ erase() [1/4]

template<typename T >
iterator Ufe::Array< T >::erase ( const_iterator  first,
const_iterator  last 
)

Removes the elements in the range [first, last).

Returns
An iterator pointing to the element that followed the last erased element,

◆ erase() [2/4]

template<typename T >
iterator Ufe::Array< T >::erase ( const_iterator  position)

Removes the element at the specified position position.

Returns
An iterator pointing to the element that followed the erased element,

◆ erase() [3/4]

template<typename T >
iterator Ufe::Array< T >::erase ( iterator  first,
iterator  last 
)

Removes the elements in the range [first, last).

Returns
An iterator pointing to the element that followed the last erased element,

◆ erase() [4/4]

template<typename T >
iterator Ufe::Array< T >::erase ( iterator  position)

Removes the element at the specified position position.

Returns
An iterator pointing to the element that followed the erased element,

◆ front() [1/2]

template<typename T >
reference Ufe::Array< T >::front ( )

Returns a reference to the first element in the array.

Note
Invokes undefined behavior if the array is empty.
Returns
A reference to the first element.

◆ front() [2/2]

template<typename T >
const_reference Ufe::Array< T >::front ( ) const

Returns a constant reference to the first element in the array.

Note
Invokes undefined behavior if the array is empty.
Returns
A constant reference to the first element.

◆ insert() [1/5]

template<typename T >
iterator Ufe::Array< T >::insert ( const_iterator  position,
const value_type val 
)

Inserts a copy of val before the element at the specified position position.

Returns
An iterator pointing to the inserted element.

◆ insert() [2/5]

template<typename T >
template<class InputIt >
std::enable_if_t<!std::is_integral_v< InputIt >, iterator > Ufe::Array< T >::insert ( const_iterator  position,
InputIt  first,
InputIt  last 
)
inline

Inserts copies of the elements in the range [first, last) before the element at the specified position position.

Returns
An iterator pointing to the first inserted element, or position if no element is inserted.

Definition at line 297 of file array.h.

◆ insert() [3/5]

template<typename T >
iterator Ufe::Array< T >::insert ( const_iterator  position,
size_type  n,
const value_type val 
)

Inserts n copies of val before the element at the specified position position.

◆ insert() [4/5]

template<typename T >
iterator Ufe::Array< T >::insert ( const_iterator  position,
std::initializer_list< value_type il 
)

Inserts copies of the elements in the initializer list il before the element at the specified position position.

Returns
An iterator pointing to the first inserted element.

◆ insert() [5/5]

template<typename T >
iterator Ufe::Array< T >::insert ( const_iterator  position,
value_type &&  val 
)

Inserts val before the element at the specified position position possibly moving it.

◆ operator!=()

template<typename T >
bool Ufe::Array< T >::operator!= ( const Array< T > &  other) const

◆ operator<()

template<typename T >
bool Ufe::Array< T >::operator< ( const Array< T > &  other) const

◆ operator<=()

template<typename T >
bool Ufe::Array< T >::operator<= ( const Array< T > &  other) const

◆ operator=() [1/3]

template<typename T >
Array & Ufe::Array< T >::operator= ( Array< T > &&  other)
noexcept

Move assignment operator.

Note
Right hand side becomes invalid object and can no longer be used in the current state. You can call clear() to reset it to an empty state.

◆ operator=() [2/3]

template<typename T >
Array & Ufe::Array< T >::operator= ( const Array< T > &  other)

Copy assignment operator.

◆ operator=() [3/3]

template<typename T >
Array & Ufe::Array< T >::operator= ( std::initializer_list< value_type il)

Initializer list assignment operator.

◆ operator==()

template<typename T >
bool Ufe::Array< T >::operator== ( const Array< T > &  other) const

◆ operator>()

template<typename T >
bool Ufe::Array< T >::operator> ( const Array< T > &  other) const

◆ operator>=()

template<typename T >
bool Ufe::Array< T >::operator>= ( const Array< T > &  other) const

◆ operator[]() [1/2]

template<typename T >
reference Ufe::Array< T >::operator[] ( size_type  n)

Returns a reference to the element at specified location n.

Note
No bounds checking is performed. If n is not within the range of the array, the behavior is undefined.
Returns
A reference to the requested element.

◆ operator[]() [2/2]

template<typename T >
const_reference Ufe::Array< T >::operator[] ( size_type  n) const

Returns a constant reference to the element at specified location n.

Note
No bounds checking is performed. If n is not within the range of the array, the behavior is undefined.
Returns
A constant reference to the requested element.

◆ pop_back()

template<typename T >
void Ufe::Array< T >::pop_back ( )

Removes the last element of the array.

Note
Calling pop_back on an empty array results in undefined behavior.

◆ push_back() [1/2]

template<typename T >
void Ufe::Array< T >::push_back ( const value_type val)

Appends an element to the end of the array.

◆ push_back() [2/2]

template<typename T >
void Ufe::Array< T >::push_back ( value_type &&  val)

Appends an element to the end of the array.

◆ rbegin() [1/2]

template<typename T >
reverse_iterator Ufe::Array< T >::rbegin ( )
inline

Returns a reverse iterator to the end of the array.

Definition at line 157 of file array.h.

◆ rbegin() [2/2]

template<typename T >
const_reverse_iterator Ufe::Array< T >::rbegin ( ) const
inline

Returns a constant reverse iterator to the end of the array.

Definition at line 160 of file array.h.

◆ rend() [1/2]

template<typename T >
reverse_iterator Ufe::Array< T >::rend ( )
inline

Returns a reverse iterator to the beginning of the array.

Definition at line 166 of file array.h.

◆ rend() [2/2]

template<typename T >
const_reverse_iterator Ufe::Array< T >::rend ( ) const
inline

Returns a constant reverse iterator to the beginning of the array.

Definition at line 169 of file array.h.

◆ reserve()

template<typename T >
void Ufe::Array< T >::reserve ( size_type  n)

Requests that the capacity be at least enough to contain n elements.

Note
If n is greater than the current capacity(), new storage is allocated, otherwise the function does nothing.

◆ resize() [1/2]

template<typename T >
void Ufe::Array< T >::resize ( size_type  count)

Resizes the array to contain count elements.

Note
If count is equal to current size, does nothing.
If the current size is greater than count, the array is reduced to its first count elements.
If the current size is less than count, additional default-inserted elements are appended.

◆ resize() [2/2]

template<typename T >
void Ufe::Array< T >::resize ( size_type  count,
const value_type value 
)

Resizes the array to contain count elements.

Note
If count is equal to current size, does nothing.
If the current size is greater than count, the array is reduced to its first count elements.
If the current size is less than count, additional copies of value are appended.

◆ size()

template<typename T >
size_type Ufe::Array< T >::size ( ) const

Returns the number of elements in the container.

◆ swap()

template<typename T >
void Ufe::Array< T >::swap ( Array< T > &  other)

Exchanges the contents and capacity of the array with those of other.

Member Data Documentation

◆ _imp

template<typename T >
std::unique_ptr<Imp> Ufe::Array< T >::_imp
private

Definition at line 401 of file array.h.


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