casacore
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ao::uvector< Tp, Alloc > Class Template Reference

A container similar to std::vector, but one that allows construction without initializing its elements. More...

#include <uvector.h>

Public Types

typedef Tp value_type
 Element type. More...
 
typedef Alloc allocator_type
 Type of allocator used to allocate and deallocate space. More...
 
typedef Tp & reference
 Reference to element type. More...
 
typedef const Tp & const_reference
 Constant reference to element type. More...
 
typedef Tp * pointer
 Pointer to element type. More...
 
typedef const Tp * const_pointer
 Pointer to constant element type. More...
 
typedef Tp * iterator
 Iterator type. More...
 
typedef const Tp * const_iterator
 Iterator type of constant elements. More...
 
typedef std::reverse_iterator< iteratorreverse_iterator
 Reverse iterator type. More...
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 Reverse iterator of constant elements. More...
 
typedef std::ptrdiff_t difference_type
 Difference between to iterators. More...
 
typedef std::size_t size_t
 Type used for indexing elements. More...
 
typedef std::size_t size_type
 Type used for indexing elements. More...
 

Public Member Functions

 uvector (const allocator_type &allocator=Alloc()) noexcept
 Construct an empty uvector. More...
 
 uvector (size_t n)
 Construct a vector with given amount of elements, without initializing these. More...
 
 uvector (size_t n, const value_type &val, const allocator_type &allocator=Alloc())
 Construct a vector with given amount of elements and set these to a specific value. More...
 
template<class InputIterator >
 uvector (InputIterator first, InputIterator last, const allocator_type &allocator=Alloc())
 Construct a vector by copying elements from a range. More...
 
 uvector (const uvector< Tp, Alloc > &other)
 Copy construct a uvector. More...
 
 uvector (const uvector< Tp, Alloc > &other, const allocator_type &allocator)
 Copy construct a uvector with custom allocator. More...
 
 uvector (uvector< Tp, Alloc > &&other) noexcept
 Move construct a uvector. More...
 
 uvector (uvector< Tp, Alloc > &&other, const allocator_type &allocator) noexcept
 Move construct a uvector with custom allocator. More...
 
 uvector (std::initializer_list< Tp > initlist, const allocator_type &allocator=Alloc())
 Construct a uvector from a initializer list. More...
 
 ~uvector () noexcept
 Destructor. More...
 
uvectoroperator= (const uvector< Tp, Alloc > &other)
 Assign another uvector to this uvector. More...
 
uvectoroperator= (uvector< Tp, Alloc > &&other) noexcept(std::allocator_traits< Alloc >::propagate_on_container_move_assignment::value||allocator_is_always_equal::value)
 Assign another uvector to this uvector. More...
 
iterator begin () noexcept
 Get iterator to first element. More...
 
const_iterator begin () const noexcept
 Get constant iterator to first element. More...
 
iterator end () noexcept
 Get iterator to element past last element. More...
 
const_iterator end () const noexcept
 Get constant iterator to element past last element. More...
 
reverse_iterator rbegin () noexcept
 Get reverse iterator to last element. More...
 
const_reverse_iterator rbegin () const noexcept
 Get constant reverse iterator to last element. More...
 
reverse_iterator rend () noexcept
 Get reverse iterator to element before first element. More...
 
const_reverse_iterator rend () const noexcept
 Get constant reverse iterator to element before first element. More...
 
const_iterator cbegin () const noexcept
 Get constant iterator to first element. More...
 
const_iterator cend () const noexcept
 Get constant iterator to element past last element. More...
 
const_reverse_iterator crbegin () const noexcept
 Get constant reverse iterator to last element. More...
 
const_reverse_iterator crend () const noexcept
 Get constant reverse iterator to element before first element. More...
 
size_t size () const noexcept
 Get number of elements in container. More...
 
size_t max_size () const noexcept
 Get maximum number of elements that this container can hold. More...
 
void resize (size_t n)
 Change the number of elements in the container. More...
 
void resize (size_t n, const Tp &val)
 Change the number of elements in the container. More...
 
size_t capacity () const noexcept
 Get the number of elements the container can currently hold without reallocating storage. More...
 
bool empty () const noexcept
 Determine if the container is currently empty. More...
 
void reserve (size_t n)
 Reserve space for a number of elements, to prevent the overhead of extra reallocations. More...
 
void shrink_to_fit ()
 Change the capacity of the container such that no extra space is hold. More...
 
Tp & operator[] (size_t index) noexcept
 Get a reference to the element at the given index. More...
 
const Tp & operator[] (size_t index) const noexcept
 Get a constant reference to the element at the given index. More...
 
Tp & at (size_t index)
 Get a reference to the element at the given index with bounds checking. More...
 
const Tp & at (size_t index) const
 Get a constant reference to the element at the given index with bounds checking. More...
 
Tp & front () noexcept
 Get reference to first element in container. More...
 
const Tp & front () const noexcept
 Get constant reference to first element in container. More...
 
Tp & back () noexcept
 Get reference to last element in container. More...
 
const Tp & back () const noexcept
 Get constant reference to last element in container. More...
 
Tp * data () noexcept
 Get pointer to internal storage. More...
 
const Tp * data () const noexcept
 Get constant pointer to internal storage. More...
 
template<class InputIterator >
void assign (InputIterator first, InputIterator last)
 Assign this container to be equal to the given range. More...
 
void assign (size_t n, const Tp &val)
 Resize the container and assign the given value to all elements. More...
 
void assign (std::initializer_list< Tp > initlist)
 Assign this container to an initializer list. More...
 
void push_back (const Tp &item)
 Add the given value to the end of the container. More...
 
void push_back (Tp &&item)
 Add the given value to the end of the container by moving it in. More...
 
void pop_back ()
 Remove the last element from the container. More...
 
iterator insert (const_iterator position, const Tp &item)
 Insert an element at a given position. More...
 
iterator insert (const_iterator position, size_t n, const Tp &val)
 Insert elements at a given position and initialize them with a value. More...
 
template<class InputIterator >
iterator insert (const_iterator position, InputIterator first, InputIterator last)
 Insert elements at a given position and initialize them from a range. More...
 
iterator insert (const_iterator position, Tp &&item)
 Insert an element at a given position by moving it in. More...
 
iterator insert (const_iterator position, std::initializer_list< Tp > initlist)
 Insert elements at a given position and initialize them from a initializer list. More...
 
iterator erase (const_iterator position)
 Delete an element from the container. More...
 
iterator erase (const_iterator first, const_iterator last)
 Delete a range of elements from the container. More...
 
void swap (uvector< Tp, Alloc > &other) noexcept
 Swap the contents of this uvector with the given uvector. More...
 
void clear ()
 Remove all elements from the container. More...
 
template<typename... Args>
iterator emplace (const_iterator position, Args &&... args)
 Insert an element at a given position by constructing it in place. More...
 
template<typename... Args>
void emplace_back (Args &&... args)
 Add the given value to the end of the container by constructing it in place. More...
 
allocator_type get_allocator () const noexcept
 Get a copy of the allocator. More...
 
iterator insert_uninitialized (const_iterator position, size_t n)
 — NON STANDARD METHODS — More...
 
template<class InputIterator >
void push_back (InputIterator first, InputIterator last)
 Add a range of items to the end of the container. More...
 
void push_back (size_t n, const Tp &val)
 Add elements at the end and initialize them with a value. More...
 
void push_back (std::initializer_list< Tp > initlist)
 Add elements from an initializer list to the end of the container. More...
 
void push_back_uninitialized (size_t n)
 Add elements at the end without initializing them. More...
 

Private Types

typedef std::false_type allocator_is_always_equal
 

Private Member Functions

pointer allocate (size_t n)
 
void deallocate () noexcept
 
void deallocate (pointer begin, size_t n) noexcept
 
template<typename InputIterator >
void construct_from_range (InputIterator first, InputIterator last, std::false_type)
 
template<typename Integral >
void construct_from_range (Integral n, Integral val, std::true_type)
 
template<typename InputIterator >
void construct_from_range (InputIterator first, InputIterator last, std::forward_iterator_tag)
 
template<typename InputIterator >
void assign_from_range (InputIterator first, InputIterator last, std::false_type)
 
template<typename Integral >
void assign_from_range (Integral n, Integral val, std::true_type)
 This function is called from assign(iter,iter) when Tp is an integral. More...
 
template<typename InputIterator >
void assign_from_range (InputIterator first, InputIterator last, std::forward_iterator_tag)
 
template<typename InputIterator >
iterator insert_from_range (const_iterator position, InputIterator first, InputIterator last, std::false_type)
 
template<typename Integral >
iterator insert_from_range (const_iterator position, Integral n, Integral val, std::true_type)
 
template<typename InputIterator >
iterator insert_from_range (const_iterator position, InputIterator first, InputIterator last, std::forward_iterator_tag)
 
void check_bounds (size_t index) const
 
size_t enlarge_size (size_t extra_space_needed) const noexcept
 
void enlarge (size_t newSize)
 
void enlarge_for_insert (size_t newSize, size_t insert_position, size_t insert_count)
 
uvectorassign_copy_from (const uvector< Tp, Alloc > &other, std::false_type)
 implementation of operator=(const&) without propagate_on_container_copy_assignment More...
 
uvectorassign_copy_from (const uvector< Tp, Alloc > &other, std::true_type)
 implementation of operator=(const&) with propagate_on_container_copy_assignment More...
 
uvectorassign_move_from (uvector< Tp, Alloc > &&other, std::false_type) noexcept(allocator_is_always_equal::value)
 implementation of operator=() without propagate_on_container_move_assignment More...
 
uvectorassign_move_from (uvector< Tp, Alloc > &&other, std::true_type) noexcept
 implementation of operator=() with propagate_on_container_move_assignment More...
 
void swap (uvector< Tp, Alloc > &other, std::true_type) noexcept
 implementation of swap with propagate_on_container_swap More...
 
void swap (uvector< Tp, Alloc > &other, std::false_type) noexcept
 implementation of swap without propagate_on_container_swap More...
 
template<typename InputIterator >
void push_back_range (InputIterator first, InputIterator last, std::false_type)
 
template<typename Integral >
void push_back_range (Integral n, Integral val, std::true_type)
 This function is called from push_back(iter,iter) when Tp is an integral. More...
 
template<typename InputIterator >
void push_back_range (InputIterator first, InputIterator last, std::forward_iterator_tag)
 

Private Attributes

pointer _begin
 
pointer _end
 
pointer _endOfStorage
 

Detailed Description

template<typename Tp, typename Alloc = std::allocator<Tp>>
class ao::uvector< Tp, Alloc >

A container similar to std::vector, but one that allows construction without initializing its elements.

This container is similar to a std::vector, except that it can be constructed without initializing its elements. This saves the overhead of initialization, hence the constructor uvector(size_t) is significantly faster than the corresponding std::vector constructor, and has no overhead compared to a manually allocated array.

Probably its greatest strength lies in the construction of containers with a number of elements that is runtime defined, but that will be initialized later. For example:

// Open a file
ifstream file("myfile.bin");
// Construct a buffer for this file
uvector<char> buffer(buffer_size);
// Read some data into the buffer
file.read(&buffer[0], buffer_size);

However, it has a few more use-cases with improved performance over std::vector. This is possible because of more strengent requirements on the element's type.

The container will behave correctly with any trivial type, but will not work for almost all non-trivial types.

The methods with different semantics compared to std::vector are:

Also the following new members are introduced:

All other members work exactly like std::vector's members, although some are slightly faster because of the stricter requirements on the element type.

Template Parameters
TpContainer's element type
AllocAllocator type. Default is to use the std::allocator.
Author
André Offringa

Definition at line 73 of file uvector.h.

Member Typedef Documentation

◆ allocator_is_always_equal

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef std::false_type ao::uvector< Tp, Alloc >::allocator_is_always_equal
private

Definition at line 80 of file uvector.h.

◆ allocator_type

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef Alloc ao::uvector< Tp, Alloc >::allocator_type

Type of allocator used to allocate and deallocate space.

Definition at line 86 of file uvector.h.

◆ const_iterator

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef const Tp* ao::uvector< Tp, Alloc >::const_iterator

Iterator type of constant elements.

Definition at line 98 of file uvector.h.

◆ const_pointer

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef const Tp* ao::uvector< Tp, Alloc >::const_pointer

Pointer to constant element type.

Definition at line 94 of file uvector.h.

◆ const_reference

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef const Tp& ao::uvector< Tp, Alloc >::const_reference

Constant reference to element type.

Definition at line 90 of file uvector.h.

◆ const_reverse_iterator

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef std::reverse_iterator<const_iterator> ao::uvector< Tp, Alloc >::const_reverse_iterator

Reverse iterator of constant elements.

Definition at line 102 of file uvector.h.

◆ difference_type

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef std::ptrdiff_t ao::uvector< Tp, Alloc >::difference_type

Difference between to iterators.

Definition at line 104 of file uvector.h.

◆ iterator

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef Tp* ao::uvector< Tp, Alloc >::iterator

Iterator type.

Definition at line 96 of file uvector.h.

◆ pointer

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef Tp* ao::uvector< Tp, Alloc >::pointer

Pointer to element type.

Definition at line 92 of file uvector.h.

◆ reference

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef Tp& ao::uvector< Tp, Alloc >::reference

Reference to element type.

Definition at line 88 of file uvector.h.

◆ reverse_iterator

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef std::reverse_iterator<iterator> ao::uvector< Tp, Alloc >::reverse_iterator

Reverse iterator type.

Definition at line 100 of file uvector.h.

◆ size_t

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef std::size_t ao::uvector< Tp, Alloc >::size_t

Type used for indexing elements.

Definition at line 106 of file uvector.h.

◆ size_type

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef std::size_t ao::uvector< Tp, Alloc >::size_type

Type used for indexing elements.

Definition at line 108 of file uvector.h.

◆ value_type

template<typename Tp , typename Alloc = std::allocator<Tp>>
typedef Tp ao::uvector< Tp, Alloc >::value_type

Element type.

Definition at line 84 of file uvector.h.

Constructor & Destructor Documentation

◆ uvector() [1/9]

template<typename Tp , typename Alloc = std::allocator<Tp>>
ao::uvector< Tp, Alloc >::uvector ( const allocator_type allocator = Alloc())
inlineexplicitnoexcept

Construct an empty uvector.

Parameters
allocatorAllocator used for allocating and deallocating memory.

Definition at line 117 of file uvector.h.

◆ uvector() [2/9]

template<typename Tp , typename Alloc = std::allocator<Tp>>
ao::uvector< Tp, Alloc >::uvector ( size_t  n)
inlineexplicit

Construct a vector with given amount of elements, without initializing these.

This constructor deviates from std::vector's behaviour, because it will not value construct its elements. It is therefore faster than the corresponding constructor of std::vector.

Parameters
nNumber of elements that the uvector will be initialized with.

Definition at line 128 of file uvector.h.

◆ uvector() [3/9]

template<typename Tp , typename Alloc = std::allocator<Tp>>
ao::uvector< Tp, Alloc >::uvector ( size_t  n,
const value_type val,
const allocator_type allocator = Alloc() 
)
inline

Construct a vector with given amount of elements and set these to a specific value.

This constructor will initialize its members with the given value.

Parameters
nNumber of elements that the uvector will be initialized with.
valValue to initialize all elements with
allocatorAllocator used for allocating and deallocating memory.

Definition at line 141 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin.

◆ uvector() [4/9]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<class InputIterator >
ao::uvector< Tp, Alloc >::uvector ( InputIterator  first,
InputIterator  last,
const allocator_type allocator = Alloc() 
)
inline

Construct a vector by copying elements from a range.

Parameters
firstIterator to range start
lastIterator to range end
allocatorAllocator used for allocating and deallocating memory.

Definition at line 156 of file uvector.h.

References first.

◆ uvector() [5/9]

template<typename Tp , typename Alloc = std::allocator<Tp>>
ao::uvector< Tp, Alloc >::uvector ( const uvector< Tp, Alloc > &  other)
inline

Copy construct a uvector.

The allocator of the new uvector will be initialized from std::allocator_traits<Alloc>::select_on_container_copy_construction(other).

Parameters
otherSource uvector to be copied from.

Definition at line 167 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, and casacore::copy().

◆ uvector() [6/9]

template<typename Tp , typename Alloc = std::allocator<Tp>>
ao::uvector< Tp, Alloc >::uvector ( const uvector< Tp, Alloc > &  other,
const allocator_type allocator 
)
inline

Copy construct a uvector with custom allocator.

Parameters
otherSource uvector to be copied from.
allocatorAllocator used for allocating and deallocating memory.

Definition at line 180 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, and casacore::copy().

◆ uvector() [7/9]

template<typename Tp , typename Alloc = std::allocator<Tp>>
ao::uvector< Tp, Alloc >::uvector ( uvector< Tp, Alloc > &&  other)
inlinenoexcept

Move construct a uvector.

Parameters
otherSource uvector to be moved from.

Definition at line 192 of file uvector.h.

◆ uvector() [8/9]

template<typename Tp , typename Alloc = std::allocator<Tp>>
ao::uvector< Tp, Alloc >::uvector ( uvector< Tp, Alloc > &&  other,
const allocator_type allocator 
)
inlinenoexcept

Move construct a uvector with custom allocator.

Parameters
otherSource uvector to be moved from.
allocatorAllocator used for allocating and deallocating memory.

Definition at line 207 of file uvector.h.

◆ uvector() [9/9]

template<typename Tp , typename Alloc = std::allocator<Tp>>
ao::uvector< Tp, Alloc >::uvector ( std::initializer_list< Tp >  initlist,
const allocator_type allocator = Alloc() 
)
inline

Construct a uvector from a initializer list.

Parameters
initlistInitializer list used for initializing the new uvector.
allocatorAllocator used for allocating and deallocating memory.

Definition at line 222 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin.

◆ ~uvector()

template<typename Tp , typename Alloc = std::allocator<Tp>>
ao::uvector< Tp, Alloc >::~uvector ( )
inlinenoexcept

Destructor.

Definition at line 237 of file uvector.h.

References ao::uvector< Tp, Alloc >::deallocate().

Member Function Documentation

◆ allocate()

template<typename Tp , typename Alloc = std::allocator<Tp>>
pointer ao::uvector< Tp, Alloc >::allocate ( size_t  n)
inlineprivate

◆ assign() [1/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<class InputIterator >
void ao::uvector< Tp, Alloc >::assign ( InputIterator  first,
InputIterator  last 
)
inline

Assign this container to be equal to the given range.

The container will be resized to fit the length of the given range. Iterators are invalidated.

Parameters
firstIterator to the beginning of the range.
lastIterator past the end of the range.

Definition at line 457 of file uvector.h.

References first.

◆ assign() [2/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::assign ( size_t  n,
const Tp &  val 
)
inline

Resize the container and assign the given value to all elements.

Iterators are invalidated.

Parameters
nNew size of container
valValue to be assigned to all elements.

Definition at line 467 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::allocate(), ao::uvector< Tp, Alloc >::capacity(), and ao::uvector< Tp, Alloc >::deallocate().

◆ assign() [3/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::assign ( std::initializer_list< Tp >  initlist)
inline

Assign this container to an initializer list.

The container will be resized to fit the length of the given initializer list. Iterators are invalidated.

Parameters
initlistList of values to assign to the container.

Definition at line 485 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::allocate(), ao::uvector< Tp, Alloc >::capacity(), and ao::uvector< Tp, Alloc >::deallocate().

◆ assign_copy_from() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
uvector& ao::uvector< Tp, Alloc >::assign_copy_from ( const uvector< Tp, Alloc > &  other,
std::false_type   
)
inlineprivate

◆ assign_copy_from() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
uvector& ao::uvector< Tp, Alloc >::assign_copy_from ( const uvector< Tp, Alloc > &  other,
std::true_type   
)
inlineprivate

◆ assign_from_range() [1/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename InputIterator >
void ao::uvector< Tp, Alloc >::assign_from_range ( InputIterator  first,
InputIterator  last,
std::false_type   
)
inlineprivate

Definition at line 886 of file uvector.h.

References first.

◆ assign_from_range() [2/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename InputIterator >
void ao::uvector< Tp, Alloc >::assign_from_range ( InputIterator  first,
InputIterator  last,
std::forward_iterator_tag   
)
inlineprivate

◆ assign_from_range() [3/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename Integral >
void ao::uvector< Tp, Alloc >::assign_from_range ( Integral  n,
Integral  val,
std::true_type   
)
inlineprivate

This function is called from assign(iter,iter) when Tp is an integral.

In that case, the user tried to call assign(n, &val), but it got caught by the wrong overload.

Definition at line 894 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::allocate(), ao::uvector< Tp, Alloc >::capacity(), and ao::uvector< Tp, Alloc >::deallocate().

◆ assign_move_from() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
uvector& ao::uvector< Tp, Alloc >::assign_move_from ( uvector< Tp, Alloc > &&  other,
std::false_type   
)
inlineprivatenoexcept

implementation of operator=() without propagate_on_container_move_assignment

We should not propagate the allocator and the allocators are different. This means we can not swap the allocated space, since then we would deallocate the space with a different allocator type. Therefore, we need to copy:

Definition at line 1042 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::assign_copy_from(), ao::uvector< Tp, Alloc >::deallocate(), and casacore::value().

Referenced by ao::uvector< Tp, Alloc >::operator=().

◆ assign_move_from() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
uvector& ao::uvector< Tp, Alloc >::assign_move_from ( uvector< Tp, Alloc > &&  other,
std::true_type   
)
inlineprivatenoexcept

◆ at() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
Tp& ao::uvector< Tp, Alloc >::at ( size_t  index)
inline

Get a reference to the element at the given index with bounds checking.

Exceptions
std::out_of_rangewhen given index is past the last element.

Definition at line 417 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, and ao::uvector< Tp, Alloc >::check_bounds().

◆ at() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
const Tp& ao::uvector< Tp, Alloc >::at ( size_t  index) const
inline

Get a constant reference to the element at the given index with bounds checking.

Exceptions
std::out_of_rangewhen given index is past the last element.

Definition at line 426 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, and ao::uvector< Tp, Alloc >::check_bounds().

◆ back() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
const Tp& ao::uvector< Tp, Alloc >::back ( ) const
inlinenoexcept

Get constant reference to last element in container.

Definition at line 442 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end.

◆ back() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
Tp& ao::uvector< Tp, Alloc >::back ( )
inlinenoexcept

Get reference to last element in container.

Definition at line 439 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end.

Referenced by dyscostman::StochasticEncoder< ValueType >::Dictionary::largest_value().

◆ begin() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
const_iterator ao::uvector< Tp, Alloc >::begin ( ) const
inlinenoexcept

Get constant iterator to first element.

Definition at line 266 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin.

◆ begin() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
iterator ao::uvector< Tp, Alloc >::begin ( )
inlinenoexcept

◆ capacity()

template<typename Tp , typename Alloc = std::allocator<Tp>>
size_t ao::uvector< Tp, Alloc >::capacity ( ) const
inlinenoexcept

◆ cbegin()

template<typename Tp , typename Alloc = std::allocator<Tp>>
const_iterator ao::uvector< Tp, Alloc >::cbegin ( ) const
inlinenoexcept

Get constant iterator to first element.

Definition at line 287 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin.

◆ cend()

template<typename Tp , typename Alloc = std::allocator<Tp>>
const_iterator ao::uvector< Tp, Alloc >::cend ( ) const
inlinenoexcept

Get constant iterator to element past last element.

Definition at line 290 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end.

◆ check_bounds()

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::check_bounds ( size_t  index) const
inlineprivate

Definition at line 974 of file uvector.h.

References ao::uvector< Tp, Alloc >::size().

Referenced by ao::uvector< Tp, Alloc >::at().

◆ clear()

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::clear ( )
inline

Remove all elements from the container.

Definition at line 701 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, and ao::uvector< Tp, Alloc >::_end.

◆ construct_from_range() [1/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename InputIterator >
void ao::uvector< Tp, Alloc >::construct_from_range ( InputIterator  first,
InputIterator  last,
std::false_type   
)
inlineprivate

Definition at line 856 of file uvector.h.

References first.

◆ construct_from_range() [2/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename InputIterator >
void ao::uvector< Tp, Alloc >::construct_from_range ( InputIterator  first,
InputIterator  last,
std::forward_iterator_tag   
)
inlineprivate

◆ construct_from_range() [3/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename Integral >
void ao::uvector< Tp, Alloc >::construct_from_range ( Integral  n,
Integral  val,
std::true_type   
)
inlineprivate

◆ crbegin()

template<typename Tp , typename Alloc = std::allocator<Tp>>
const_reverse_iterator ao::uvector< Tp, Alloc >::crbegin ( ) const
inlinenoexcept

Get constant reverse iterator to last element.

Definition at line 293 of file uvector.h.

References ao::uvector< Tp, Alloc >::end().

◆ crend()

template<typename Tp , typename Alloc = std::allocator<Tp>>
const_reverse_iterator ao::uvector< Tp, Alloc >::crend ( ) const
inlinenoexcept

Get constant reverse iterator to element before first element.

Definition at line 296 of file uvector.h.

References ao::uvector< Tp, Alloc >::begin().

◆ data() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
const Tp* ao::uvector< Tp, Alloc >::data ( ) const
inlinenoexcept

Get constant pointer to internal storage.

Definition at line 448 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin.

◆ data() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
Tp* ao::uvector< Tp, Alloc >::data ( )
inlinenoexcept

Get pointer to internal storage.

Definition at line 445 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin.

◆ deallocate() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::deallocate ( )
inlineprivatenoexcept

◆ deallocate() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::deallocate ( pointer  begin,
size_t  n 
)
inlineprivatenoexcept

Definition at line 849 of file uvector.h.

References ao::uvector< Tp, Alloc >::begin().

◆ emplace()

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename... Args>
iterator ao::uvector< Tp, Alloc >::emplace ( const_iterator  position,
Args &&...  args 
)
inline

Insert an element at a given position by constructing it in place.

All iterators will be invalidated. This operation needs to move all elements after the new element, and can therefore be expensive.

Parameters
positionPosition of the new element. The new element will be added before the old element at that position.
argsList of arguments to be forwarded to construct the new element.
Returns
Position of the new element.

Definition at line 715 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::enlarge_for_insert(), and ao::uvector< Tp, Alloc >::enlarge_size().

◆ emplace_back()

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename... Args>
void ao::uvector< Tp, Alloc >::emplace_back ( Args &&...  args)
inline

Add the given value to the end of the container by constructing it in place.

Iterators are invalidated.

Parameters
argsList of arguments to be forwarded to construct the new element.

Definition at line 736 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::enlarge(), and ao::uvector< Tp, Alloc >::enlarge_size().

◆ empty()

template<typename Tp , typename Alloc = std::allocator<Tp>>
bool ao::uvector< Tp, Alloc >::empty ( ) const
inlinenoexcept

Determine if the container is currently empty.

Returns
true if size() == 0.

Definition at line 357 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, and ao::uvector< Tp, Alloc >::_end.

◆ end() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
const_iterator ao::uvector< Tp, Alloc >::end ( ) const
inlinenoexcept

Get constant iterator to element past last element.

Definition at line 272 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end.

◆ end() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
iterator ao::uvector< Tp, Alloc >::end ( )
inlinenoexcept

◆ enlarge()

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::enlarge ( size_t  newSize)
inlineprivate

◆ enlarge_for_insert()

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::enlarge_for_insert ( size_t  newSize,
size_t  insert_position,
size_t  insert_count 
)
inlineprivate

◆ enlarge_size()

template<typename Tp , typename Alloc = std::allocator<Tp>>
size_t ao::uvector< Tp, Alloc >::enlarge_size ( size_t  extra_space_needed) const
inlineprivatenoexcept

◆ erase() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
iterator ao::uvector< Tp, Alloc >::erase ( const_iterator  first,
const_iterator  last 
)
inline

Delete a range of elements from the container.

This operation moves all elements past the removed elements, and can therefore be expensive.

Parameters
firstPosition of first element to be removed.
lastPosition past last element to be removed.
Returns
Iterator pointing to the first element past the delete element.

Definition at line 677 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end, and first.

◆ erase() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
iterator ao::uvector< Tp, Alloc >::erase ( const_iterator  position)
inline

Delete an element from the container.

This operation moves all elements past the removed element, and can therefore be expensive.

Parameters
positionPosition of element to be removed.
Returns
Iterator pointing to the first element past the delete element.

Definition at line 663 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end.

◆ front() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
const Tp& ao::uvector< Tp, Alloc >::front ( ) const
inlinenoexcept

Get constant reference to first element in container.

Definition at line 436 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin.

◆ front() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
Tp& ao::uvector< Tp, Alloc >::front ( )
inlinenoexcept

Get reference to first element in container.

Definition at line 433 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin.

Referenced by dyscostman::StochasticEncoder< ValueType >::Dictionary::smallest_value().

◆ get_allocator()

template<typename Tp , typename Alloc = std::allocator<Tp>>
allocator_type ao::uvector< Tp, Alloc >::get_allocator ( ) const
inlinenoexcept

Get a copy of the allocator.

Definition at line 745 of file uvector.h.

◆ insert() [1/5]

template<typename Tp , typename Alloc = std::allocator<Tp>>
iterator ao::uvector< Tp, Alloc >::insert ( const_iterator  position,
const Tp &  item 
)
inline

Insert an element at a given position.

All iterators will be invalidated. This operation needs to move all elements after the new element, and can therefore be expensive.

Parameters
positionPosition of the new element. The new element will be added before the old element at that position.
itemValue of the new item.
Returns
Position of the new element.

Definition at line 544 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::enlarge_for_insert(), and ao::uvector< Tp, Alloc >::enlarge_size().

◆ insert() [2/5]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<class InputIterator >
iterator ao::uvector< Tp, Alloc >::insert ( const_iterator  position,
InputIterator  first,
InputIterator  last 
)
inline

Insert elements at a given position and initialize them from a range.

All iterators will be invalidated. This operation needs to move all elements after the new element, and can therefore be expensive.

Parameters
positionPosition of the new elements. The new elements will be added before the old element at that position.
firstIterator to the beginning of the range.
lastIterator past the end of the range.
Returns
Position of the first new element.

Definition at line 595 of file uvector.h.

References first.

◆ insert() [3/5]

template<typename Tp , typename Alloc = std::allocator<Tp>>
iterator ao::uvector< Tp, Alloc >::insert ( const_iterator  position,
size_t  n,
const Tp &  val 
)
inline

Insert elements at a given position and initialize them with a value.

All iterators will be invalidated. This operation needs to move all elements after the new element, and can therefore be expensive.

Parameters
positionPosition of the new elements. The new elements will be added before the old element at that position.
nNumber of elements to add.
valValue of the new item.
Returns
Position of the first new element.

Definition at line 569 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::capacity(), ao::uvector< Tp, Alloc >::enlarge_for_insert(), ao::uvector< Tp, Alloc >::enlarge_size(), and ao::uvector< Tp, Alloc >::size().

◆ insert() [4/5]

template<typename Tp , typename Alloc = std::allocator<Tp>>
iterator ao::uvector< Tp, Alloc >::insert ( const_iterator  position,
std::initializer_list< Tp >  initlist 
)
inline

Insert elements at a given position and initialize them from a initializer list.

All iterators will be invalidated. This operation needs to move all elements after the new element, and can therefore be expensive.

Parameters
positionPosition of the new elements. The new elements will be added before the old element at that position.
initlistList of items to insert.
Returns
Position of the first new element.

Definition at line 636 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::capacity(), ao::uvector< Tp, Alloc >::enlarge_for_insert(), ao::uvector< Tp, Alloc >::enlarge_size(), and ao::uvector< Tp, Alloc >::size().

◆ insert() [5/5]

template<typename Tp , typename Alloc = std::allocator<Tp>>
iterator ao::uvector< Tp, Alloc >::insert ( const_iterator  position,
Tp &&  item 
)
inline

Insert an element at a given position by moving it in.

All iterators will be invalidated. This operation needs to move all elements after the new element, and can therefore be expensive.

Note that this container can only hold simple types that do not perform allocations. Therefore, there is probably no benefit in moving the new item in over copying it in with insert(const_iterator, const Tp&).

Parameters
positionPosition of the new element. The new element will be added before the old element at that position.
itemValue of the new item.
Returns
Position of the new element.

Definition at line 612 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::enlarge_for_insert(), and ao::uvector< Tp, Alloc >::enlarge_size().

◆ insert_from_range() [1/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename InputIterator >
iterator ao::uvector< Tp, Alloc >::insert_from_range ( const_iterator  position,
InputIterator  first,
InputIterator  last,
std::false_type   
)
inlineprivate

Definition at line 928 of file uvector.h.

References first.

◆ insert_from_range() [2/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename InputIterator >
iterator ao::uvector< Tp, Alloc >::insert_from_range ( const_iterator  position,
InputIterator  first,
InputIterator  last,
std::forward_iterator_tag   
)
inlineprivate

◆ insert_from_range() [3/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename Integral >
iterator ao::uvector< Tp, Alloc >::insert_from_range ( const_iterator  position,
Integral  n,
Integral  val,
std::true_type   
)
inlineprivate

◆ insert_uninitialized()

template<typename Tp , typename Alloc = std::allocator<Tp>>
iterator ao::uvector< Tp, Alloc >::insert_uninitialized ( const_iterator  position,
size_t  n 
)
inline

— NON STANDARD METHODS —

Insert elements at a given position without initializing them.

All iterators will be invalidated. This operation needs to move all elements after the new element, and can therefore be expensive. It will not initialize the new elements, and is therefore faster than insert(const_iterator, size_t, const Tp&).

This method is non-standard: it is not present in std::vector.

Parameters
positionPosition of the new elements. The new elements will be added before the old element at that position.
nNumber of elements to add.

Definition at line 762 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::capacity(), ao::uvector< Tp, Alloc >::enlarge_for_insert(), ao::uvector< Tp, Alloc >::enlarge_size(), and ao::uvector< Tp, Alloc >::size().

◆ max_size()

template<typename Tp , typename Alloc = std::allocator<Tp>>
size_t ao::uvector< Tp, Alloc >::max_size ( ) const
inlinenoexcept

Get maximum number of elements that this container can hold.

Definition at line 302 of file uvector.h.

◆ operator=() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
uvector& ao::uvector< Tp, Alloc >::operator= ( const uvector< Tp, Alloc > &  other)
inline

Assign another uvector to this uvector.

The allocator of the uvector will be assigned to other when std::allocator_traits<Alloc>::propagate_on_container_copy_assignment() is of true_type.

Definition at line 246 of file uvector.h.

References ao::uvector< Tp, Alloc >::assign_copy_from().

◆ operator=() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
uvector& ao::uvector< Tp, Alloc >::operator= ( uvector< Tp, Alloc > &&  other)
inlinenoexcept

Assign another uvector to this uvector.

The allocator of the uvector will be assigned to other when std::allocator_traits<Alloc>::propagate_on_container_move_assignment() is of true_type.

Definition at line 255 of file uvector.h.

References ao::uvector< Tp, Alloc >::assign_move_from().

◆ operator[]() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
const Tp& ao::uvector< Tp, Alloc >::operator[] ( size_t  index) const
inlinenoexcept

Get a constant reference to the element at the given index.

Definition at line 412 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin.

◆ operator[]() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
Tp& ao::uvector< Tp, Alloc >::operator[] ( size_t  index)
inlinenoexcept

Get a reference to the element at the given index.

Definition at line 409 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin.

◆ pop_back()

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::pop_back ( )
inline

Remove the last element from the container.

Definition at line 531 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end.

◆ push_back() [1/5]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::push_back ( const Tp &  item)
inline

Add the given value to the end of the container.

Iterators are invalidated.

Parameters
itemValue of new element.

Definition at line 507 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::enlarge(), and ao::uvector< Tp, Alloc >::enlarge_size().

◆ push_back() [2/5]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<class InputIterator >
void ao::uvector< Tp, Alloc >::push_back ( InputIterator  first,
InputIterator  last 
)
inline

Add a range of items to the end of the container.

All iterators will be invalidated.

This method is non-standard: it is not present in std::vector.

Parameters
firstIterator to the beginning of the range.
lastIterator past the end of the range.

Definition at line 785 of file uvector.h.

References first.

◆ push_back() [3/5]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::push_back ( size_t  n,
const Tp &  val 
)
inline

Add elements at the end and initialize them with a value.

All iterators will be invalidated.

This method is non-standard: it is not present in std::vector.

Parameters
nNumber of elements to add.
valValue of the new items.

Definition at line 797 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::capacity(), ao::uvector< Tp, Alloc >::enlarge(), ao::uvector< Tp, Alloc >::enlarge_size(), and ao::uvector< Tp, Alloc >::size().

◆ push_back() [4/5]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::push_back ( std::initializer_list< Tp >  initlist)
inline

Add elements from an initializer list to the end of the container.

All iterators will be invalidated.

This method is non-standard: it is not present in std::vector.

Parameters
initlistThe list with values to add.

Definition at line 813 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::capacity(), ao::uvector< Tp, Alloc >::enlarge(), ao::uvector< Tp, Alloc >::enlarge_size(), and ao::uvector< Tp, Alloc >::size().

◆ push_back() [5/5]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::push_back ( Tp &&  item)
inline

Add the given value to the end of the container by moving it in.

Iterators are invalidated.

Note that this container can only hold simple types that do not perform allocations. Therefore, there is probably no benefit in moving the new item in over copying it in with push_back(const Tp&).

Parameters
itemValue of new element.

Definition at line 522 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::enlarge(), and ao::uvector< Tp, Alloc >::enlarge_size().

◆ push_back_range() [1/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename InputIterator >
void ao::uvector< Tp, Alloc >::push_back_range ( InputIterator  first,
InputIterator  last,
std::false_type   
)
inlineprivate

Definition at line 1117 of file uvector.h.

References first.

◆ push_back_range() [2/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename InputIterator >
void ao::uvector< Tp, Alloc >::push_back_range ( InputIterator  first,
InputIterator  last,
std::forward_iterator_tag   
)
inlineprivate

◆ push_back_range() [3/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
template<typename Integral >
void ao::uvector< Tp, Alloc >::push_back_range ( Integral  n,
Integral  val,
std::true_type   
)
inlineprivate

This function is called from push_back(iter,iter) when Tp is an integral.

In that case, the user tried to call push_back(n, &val), but it got caught by the wrong overload.

Definition at line 1125 of file uvector.h.

References ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::capacity(), ao::uvector< Tp, Alloc >::enlarge(), ao::uvector< Tp, Alloc >::enlarge_size(), and ao::uvector< Tp, Alloc >::size().

◆ push_back_uninitialized()

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::push_back_uninitialized ( size_t  n)
inline

Add elements at the end without initializing them.

All iterators will be invalidated.

This method is non-standard: it is not present in std::vector.

Parameters
nNumber of elements to add.

Definition at line 832 of file uvector.h.

References ao::uvector< Tp, Alloc >::resize(), and ao::uvector< Tp, Alloc >::size().

◆ rbegin() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
const_reverse_iterator ao::uvector< Tp, Alloc >::rbegin ( ) const
inlinenoexcept

Get constant reverse iterator to last element.

Definition at line 278 of file uvector.h.

References ao::uvector< Tp, Alloc >::end().

◆ rbegin() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
reverse_iterator ao::uvector< Tp, Alloc >::rbegin ( )
inlinenoexcept

Get reverse iterator to last element.

Definition at line 275 of file uvector.h.

References ao::uvector< Tp, Alloc >::end().

◆ rend() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
const_reverse_iterator ao::uvector< Tp, Alloc >::rend ( ) const
inlinenoexcept

Get constant reverse iterator to element before first element.

Definition at line 284 of file uvector.h.

References ao::uvector< Tp, Alloc >::begin().

◆ rend() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
reverse_iterator ao::uvector< Tp, Alloc >::rend ( )
inlinenoexcept

Get reverse iterator to element before first element.

Definition at line 281 of file uvector.h.

References ao::uvector< Tp, Alloc >::begin().

◆ reserve()

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::reserve ( size_t  n)
inline

Reserve space for a number of elements, to prevent the overhead of extra reallocations.

This has no effect on the working of the uvector, except that it might change the current capacity. This can enhance performance when a large number of elements are added, and an approximate size is known a priori.

This method might cause a reallocation, causing iterators to be invalidated.

Parameters
nNumber of elements to reserve space for.

Definition at line 368 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::allocate(), ao::uvector< Tp, Alloc >::capacity(), ao::uvector< Tp, Alloc >::deallocate(), and ao::uvector< Tp, Alloc >::size().

Referenced by dyscostman::StochasticEncoder< ValueType >::Dictionary::reserve().

◆ resize() [1/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::resize ( size_t  n)
inline

Change the number of elements in the container.

If the new size is larger than the current size, new values will be left uninitialized. Therefore, it is more efficient than resize(size_t) in std::vector, as well as resize(size_t, const Tp&). If the new size is smaller than the current size, the container will be truncated and elements past the new size will be removed. No destructor of the removed elements will be called.

Parameters
nThe new size of the container.

Definition at line 313 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::allocate(), ao::uvector< Tp, Alloc >::capacity(), ao::uvector< Tp, Alloc >::deallocate(), and ao::uvector< Tp, Alloc >::enlarge_size().

Referenced by ao::uvector< Tp, Alloc >::push_back_uninitialized(), and dyscostman::StochasticEncoder< ValueType >::Dictionary::resize().

◆ resize() [2/2]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::resize ( size_t  n,
const Tp &  val 
)
inline

Change the number of elements in the container.

If the new size is larger than the current size, new values will be initialized by the given value. If the new size is smaller than the current size, the container will be truncated and elements past the new size will be removed. No destructor of the removed elements will be called.

Parameters
nThe new size of the container.
valNew value of elements that get added to the container.

Definition at line 336 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::allocate(), ao::uvector< Tp, Alloc >::capacity(), ao::uvector< Tp, Alloc >::deallocate(), and ao::uvector< Tp, Alloc >::size().

◆ shrink_to_fit()

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::shrink_to_fit ( )
inline

Change the capacity of the container such that no extra space is hold.

This has no effect on the working of the uvector, except that it might change the current capacity. This can reduce the current memory usage of the container.

This method might cause a reallocation, causing iterators to be invalidated.

Definition at line 388 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, ao::uvector< Tp, Alloc >::allocate(), ao::uvector< Tp, Alloc >::capacity(), ao::uvector< Tp, Alloc >::deallocate(), and ao::uvector< Tp, Alloc >::size().

◆ size()

template<typename Tp , typename Alloc = std::allocator<Tp>>
size_t ao::uvector< Tp, Alloc >::size ( ) const
inlinenoexcept

◆ swap() [1/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::swap ( uvector< Tp, Alloc > &  other)
inlinenoexcept

Swap the contents of this uvector with the given uvector.

Iterators to both vectors will remain valid and will point into to the swapped container afterwards. This function will never reallocate space.

The allocator will be swapped when the propagate_on_container_swap of the respective allocator_trait is true_type. Its behaviour is undefined when the allocators do not compare equal and propagate_on_container_swap is false.

Parameters
otherOther uvector whose contents it to be swapped with this.

Definition at line 695 of file uvector.h.

Referenced by ao::swap().

◆ swap() [2/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::swap ( uvector< Tp, Alloc > &  other,
std::false_type   
)
inlineprivatenoexcept

implementation of swap without propagate_on_container_swap

We have two choices here:

  • Do not swap the allocators. For stateful allocators, we would need to reallocate memory, and iterators would not be valid UNLESS they were stored as indices. However, containers with stateful allocators are not allowed to be swapped unless the allocators are equal, in which case swapping is not necessary.
  • Swap the allocators. This would not reallocate memory and iterators remain valid, but the trait ignores propagate_on_container_swap.

The standard says: "Allocator replacement is performed by copy assignment, move assignment, or swapping of the allocator only if allocator_traits<allocatortype>:: propagate_on_container_copy_assignment::value, allocator_traits<allocatortype>::propagate_on_container_move_assignment::value, or allocator_traits<allocatortype>::propagate_on_container_swap::value is true within the implementation of the corresponding container operation. The behavior of a call to a container’s swap function is undefined unless the objects being swapped have allocators that compare equal or allocator_traits<allocatortype>::propagate_on_container_swap::value is true."

Definition at line 1088 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, and ao::swap().

◆ swap() [3/3]

template<typename Tp , typename Alloc = std::allocator<Tp>>
void ao::uvector< Tp, Alloc >::swap ( uvector< Tp, Alloc > &  other,
std::true_type   
)
inlineprivatenoexcept

implementation of swap with propagate_on_container_swap

Definition at line 1079 of file uvector.h.

References ao::uvector< Tp, Alloc >::_begin, ao::uvector< Tp, Alloc >::_end, ao::uvector< Tp, Alloc >::_endOfStorage, and ao::swap().

Member Data Documentation

◆ _begin

template<typename Tp , typename Alloc = std::allocator<Tp>>
pointer ao::uvector< Tp, Alloc >::_begin
private

◆ _end

template<typename Tp , typename Alloc = std::allocator<Tp>>
pointer ao::uvector< Tp, Alloc >::_end
private

◆ _endOfStorage

template<typename Tp , typename Alloc = std::allocator<Tp>>
pointer ao::uvector< Tp, Alloc >::_endOfStorage
private

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