VectorPro
High-performance, header-only dynamic array with configurable growth policy, custom allocator support, and optional modification-event notifications.
Loading...
Searching...
No Matches
VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents > Class Template Reference

A dynamically resizable contiguous array. More...

#include <Vector.h>

Classes

struct  EventData
 Describes a vector modification event. More...
 

Public Types

enum class  EventType : std::uint8_t {
  PUSHBACK , EMPLACEBACK , POPBACK , INSERT ,
  REMOVE , ERASE , CLEAR , SHRINK ,
  RESERVE
}
 Event types emitted when the vector is modified. More...
 
using allocator_type = Allocator
 
using value_type = T
 
using pointer = typename std::allocator_traits< Allocator >::pointer
 
using const_pointer = typename std::allocator_traits< Allocator >::const_pointer
 
using reference = T &
 
using const_reference = const T &
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using ListenerFn = std::function< void(const Vector &, EventData)>
 Callback type invoked with the vector and the event that occurred.
 
using ListenerHandle = std::size_t
 Opaque handle returned by subscribe(), used to unsubscribe() later.
 
using iterator = VectorPro::Iterator< T >
 
using const_iterator = VectorPro::Iterator< const T >
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 

Public Member Functions

 Vector (std::size_t count, const T &value={})
 Constructs a vector with count copies of value.
 
 Vector (std::initializer_list< T > init)
 Constructs a vector from an initializer list.
 
template<std::input_iterator It>
 Vector (It first, It last)
 Constructs a vector from an iterator range via repeated push_back().
 
 Vector (const Allocator &alloc=Allocator{})
 Constructs an empty vector with no allocated storage.
 
 ~Vector () noexcept
 Destroys all elements and releases storage.
 
 Vector (const Vector &other)
 Copy-constructs a vector, deep-copying other's elements.
 
Vector & operator= (const Vector &other)
 Copy-assigns from other, replacing this vector's contents.
 
 Vector (Vector &&other) noexcept
 Move-constructs a vector, taking ownership of other's storage.
 
Vector & operator= (Vector &&other) noexcept
 Move-assigns from other, replacing this vector's contents.
 
void push_back (const T &value)
 Appends a copy of value to the end, growing capacity if needed.
 
void push_back (T &&value)
 Appends value to the end by move, growing capacity if needed.
 
template<typename... Args>
requires std::constructible_from<T, Args...>
void emplace_back (Args &&... args)
 Constructs a new element in place at the end of the vector.
 
iterator insert (const_iterator pos, const T &value)
 Inserts a copy of value before pos.
 
iterator insert (const_iterator pos, T &&value)
 Inserts value before pos by move.
 
template<std::input_iterator It>
iterator insert (const_iterator pos, It first, It last)
 Inserts a copy of each element in [first, last) before pos.
 
template<typename... Args>
requires std::constructible_from<T, Args...>
iterator emplace (const_iterator pos, Args &&... args)
 Constructs a new element in place before pos.
 
template<typename Predicate >
requires std::predicate<Predicate, const T&>
std::size_t remove_if (Predicate pred)
 Removes all elements for which pred returns true.
 
void pop_back ()
 Removes the last element. No-op if the vector is empty.
 
iterator erase (const_iterator pos)
 Erases the element at pos.
 
iterator erase (const_iterator first, const_iterator last)
 Erases the elements in [first, last).
 
void clear () noexcept
 Destroys all elements, leaving the vector empty. Capacity is unchanged.
 
void reserve (std::size_t newCap)
 Ensures capacity is at least newCap, reallocating if needed.
 
void shrink_to_fit ()
 Reduces capacity to match the current size, reallocating if needed.
 
template<typename F >
requires EnableEvents
&&Listener< F, Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents > > ListenerHandle subscribe (F &&listeners)
 Registers a listener to be notified of modification events.
 
void unsubscribe (ListenerHandle handle)
 Removes a previously registered listener.
 
bool operator== (const Vector &other) const noexcept(noexcept(std::declval< const T & >()==std::declval< const T & >()))
 Compares two vectors for equality.
 
auto operator<=> (const Vector &other) const noexcept(noexcept(std::declval< const T & >()<=> std::declval< const T & >()))
 Lexicographically compares two vectors.
 
std::span< T > as_span () noexcept
 Returns a mutable span over the vector's current elements.
 
std::span< const T > as_span () const noexcept
 Returns a read-only span over the vector's current elements.
 
pointer data_ptr () noexcept
 Returns a pointer to the underlying contiguous storage.
 
const_pointer data_ptr () const noexcept
 Returns a const pointer to the underlying contiguous storage.
 
reference at (std::size_t index)
 Returns a reference to the element at index, with bounds checking.
 
const_reference at (std::size_t index) const
 Returns a const reference to the element at index, with bounds checking.
 
reference front ()
 Returns a reference to the first element. Undefined behavior if empty.
 
const_reference front () const
 Returns a const reference to the first element. Undefined behavior if empty.
 
reference back ()
 Returns a reference to the last element. Undefined behavior if empty.
 
const_reference back () const
 Returns a const reference to the last element. Undefined behavior if empty.
 
reference operator[] (std::size_t index) noexcept
 Returns a reference to the element at index, without bounds checking.
 
const_reference operator[] (std::size_t index) const noexcept
 Returns a const reference to the element at index, without bounds checking.
 
bool contains (const T &value) const noexcept(noexcept(std::declval< const T & >()==std::declval< const T & >()))
 Checks whether value is present in the vector.
 
iterator find (const T &value) noexcept(noexcept(std::declval< const T & >()==std::declval< const T & >()))
 Finds the first element equal to value.
 
const_iterator find (const T &value) const noexcept(noexcept(std::declval< const T & >()==std::declval< const T & >()))
 Finds the first element equal to value.
 
void swap (Vector &other) noexcept
 Exchanges the contents of two vectors, including allocators.
 
bool empty () const noexcept
 Returns whether the vector has no elements.
 
std::size_t size () const noexcept
 Returns the number of elements currently stored.
 
std::size_t capacity () const noexcept
 Returns the number of elements the vector can hold without reallocating.
 
iterator begin () noexcept
 Returns an iterator to the first element.
 
iterator end () noexcept
 Returns an iterator one past the last element.
 
const_iterator begin () const noexcept
 Returns a const iterator to the first element.
 
const_iterator end () const noexcept
 Returns a const iterator one past the last element.
 
const_iterator cbegin () const noexcept
 Returns a const iterator to the first element.
 
const_iterator cend () const noexcept
 Returns a const iterator one past the last element.
 
reverse_iterator rbegin () noexcept
 Returns a reverse iterator to the last element.
 
reverse_iterator rend () noexcept
 Returns a reverse iterator one before the first element.
 
const_reverse_iterator rbegin () const noexcept
 Returns a const reverse iterator to the last element.
 
const_reverse_iterator rend () const noexcept
 Returns a const reverse iterator one before the first element.
 
const_reverse_iterator crbegin () const noexcept
 Returns a const reverse iterator to the last element.
 
const_reverse_iterator crend () const noexcept
 Returns a const reverse iterator one before the first element.
 

Detailed Description

template<typename T, typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
requires std::destructible<T>
class VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >

A dynamically resizable contiguous array.

Template Parameters
TElement type. Must satisfy std::destructible.
AllocatorAllocator type used for storage. Defaults to std::allocator<T>.
GrowthNumNumerator of the capacity growth factor (GrowthNum / GrowthDen).
GrowthDenDenominator of the capacity growth factor.
EnableEventsWhether modification-event notifications (subscribe()/ unsubscribe()) are compiled in. Defaults to false; when disabled, no listener storage exists and no notification code is emitted anywhere in the class — see VectorPro::ObservableVector for the enabled alias.

Provides std::vector-like semantics with configurable growth, custom allocator support, iterator support, and modification event notifications. GrowthNum must be greater than GrowthDen so that capacity strictly increases on each reallocation.

Member Typedef Documentation

◆ allocator_type

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::allocator_type = Allocator

◆ const_iterator

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::const_iterator = VectorPro::Iterator<const T>

◆ const_pointer

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::const_pointer = typename std::allocator_traits<Allocator>::const_pointer

◆ const_reference

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::const_reference = const T&

◆ const_reverse_iterator

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::const_reverse_iterator = std::reverse_iterator<const_iterator>

◆ difference_type

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::difference_type = std::ptrdiff_t

◆ iterator

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::iterator = VectorPro::Iterator<T>

◆ ListenerFn

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::ListenerFn = std::function<void(const Vector&, EventData)>

Callback type invoked with the vector and the event that occurred.

◆ ListenerHandle

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::ListenerHandle = std::size_t

Opaque handle returned by subscribe(), used to unsubscribe() later.

◆ pointer

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::pointer = typename std::allocator_traits<Allocator>::pointer

◆ reference

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::reference = T&

◆ reverse_iterator

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::reverse_iterator = std::reverse_iterator<iterator>

◆ size_type

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::size_type = std::size_t

◆ value_type

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
using VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::value_type = T

Member Enumeration Documentation

◆ EventType

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
enum class VectorPro::Vector::EventType : std::uint8_t
strong

Event types emitted when the vector is modified.

Enumerator
PUSHBACK 

Emitted by push_back().

EMPLACEBACK 

Emitted by emplace_back().

POPBACK 

Emitted by pop_back().

INSERT 

Emitted by insert() and emplace().

REMOVE 

Emitted by remove_if().

ERASE 

Emitted by erase().

CLEAR 

Emitted by clear().

SHRINK 

Emitted by shrink_to_fit().

RESERVE 

Emitted by reserve().

Constructor & Destructor Documentation

◆ Vector() [1/6]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::Vector ( std::size_t  count,
const T &  value = {} 
)
explicit

Constructs a vector with count copies of value.

Parameters
countNumber of elements to construct.
valueValue used to initialize each element. Defaults to T{}.

◆ Vector() [2/6]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::Vector ( std::initializer_list< T >  init)

Constructs a vector from an initializer list.

Parameters
initElements to copy into the vector, in order.

◆ Vector() [3/6]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
template<std::input_iterator It>
VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::Vector ( It  first,
It  last 
)

Constructs a vector from an iterator range via repeated push_back().

Template Parameters
ItInput iterator type.
Parameters
firstIterator to the first element to copy.
lastIterator one past the last element to copy.

◆ Vector() [4/6]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::Vector ( const Allocator &  alloc = Allocator{})
explicit

Constructs an empty vector with no allocated storage.

Parameters
allocAllocator instance to use. Defaults to Allocator{}.

◆ ~Vector()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::~Vector ( )
noexcept

Destroys all elements and releases storage.

◆ Vector() [5/6]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::Vector ( const Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents > &  other)

Copy-constructs a vector, deep-copying other's elements.

Parameters
otherVector to copy from.

◆ Vector() [6/6]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::Vector ( Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents > &&  other)
noexcept

Move-constructs a vector, taking ownership of other's storage.

Parameters
otherVector to move from, left empty afterward.

Member Function Documentation

◆ as_span() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
std::span< const T > VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::as_span ( ) const
noexcept

Returns a read-only span over the vector's current elements.

◆ as_span() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
std::span< T > VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::as_span ( )
noexcept

Returns a mutable span over the vector's current elements.

◆ at() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
reference VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::at ( std::size_t  index)

Returns a reference to the element at index, with bounds checking.

Parameters
indexZero-based index of the element to access.
Returns
Reference to the element at index.
Exceptions
std::out_of_rangeif index >= size().

◆ at() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_reference VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::at ( std::size_t  index) const

Returns a const reference to the element at index, with bounds checking.

Parameters
indexZero-based index of the element to access.
Returns
Const reference to the element at index.
Exceptions
std::out_of_rangeif index >= size().

◆ back() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
reference VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::back ( )

Returns a reference to the last element. Undefined behavior if empty.

◆ back() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_reference VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::back ( ) const

Returns a const reference to the last element. Undefined behavior if empty.

◆ begin() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::begin ( ) const
noexcept

Returns a const iterator to the first element.

◆ begin() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::begin ( )
noexcept

Returns an iterator to the first element.

◆ capacity()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
std::size_t VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::capacity ( ) const
noexcept

Returns the number of elements the vector can hold without reallocating.

◆ cbegin()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::cbegin ( ) const
noexcept

Returns a const iterator to the first element.

◆ cend()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::cend ( ) const
noexcept

Returns a const iterator one past the last element.

◆ clear()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
void VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::clear ( )
noexcept

Destroys all elements, leaving the vector empty. Capacity is unchanged.

◆ contains()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
bool VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::contains ( const T &  value) const &
noexcept

Checks whether value is present in the vector.

Parameters
valueValue to search for.
Returns
true if an equal element is found.

◆ crbegin()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_reverse_iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::crbegin ( ) const
noexcept

Returns a const reverse iterator to the last element.

◆ crend()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_reverse_iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::crend ( ) const
noexcept

Returns a const reverse iterator one before the first element.

◆ data_ptr() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_pointer VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::data_ptr ( ) const
noexcept

Returns a const pointer to the underlying contiguous storage.

◆ data_ptr() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
pointer VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::data_ptr ( )
noexcept

Returns a pointer to the underlying contiguous storage.

◆ emplace()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
template<typename... Args>
requires std::constructible_from<T, Args...>
iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::emplace ( const_iterator  pos,
Args &&...  args 
)

Constructs a new element in place before pos.

Template Parameters
ArgsConstructor argument types for T.
Parameters
posPosition to insert before.
argsArguments forwarded to T's constructor.
Returns
Iterator pointing to the newly constructed element.

◆ emplace_back()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
template<typename... Args>
requires std::constructible_from<T, Args...>
void VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::emplace_back ( Args &&...  args)

Constructs a new element in place at the end of the vector.

Template Parameters
ArgsConstructor argument types for T.
Parameters
argsArguments forwarded to T's constructor.

◆ empty()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
bool VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::empty ( ) const
noexcept

Returns whether the vector has no elements.

◆ end() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::end ( ) const
noexcept

Returns a const iterator one past the last element.

◆ end() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::end ( )
noexcept

Returns an iterator one past the last element.

◆ erase() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::erase ( const_iterator  first,
const_iterator  last 
)

Erases the elements in [first, last).

Parameters
firstIterator to the first element to erase.
lastIterator one past the last element to erase.
Returns
Iterator to the element that followed the erased range.

◆ erase() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::erase ( const_iterator  pos)

Erases the element at pos.

Parameters
posPosition of the element to erase.
Returns
Iterator to the element that followed the erased one.

◆ find() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::find ( const T &  value) const &
noexcept

Finds the first element equal to value.

Parameters
valueValue to search for.
Returns
Const iterator to the found element, or end() if not found.

◆ find() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::find ( const T &  value) const &
noexcept

Finds the first element equal to value.

Parameters
valueValue to search for.
Returns
Iterator to the found element, or end() if not found.

◆ front() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
reference VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::front ( )

Returns a reference to the first element. Undefined behavior if empty.

◆ front() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_reference VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::front ( ) const

Returns a const reference to the first element. Undefined behavior if empty.

◆ insert() [1/3]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::insert ( const_iterator  pos,
const T &  value 
)

Inserts a copy of value before pos.

Parameters
posPosition to insert before.
valueValue to insert. Safe to pass a reference into this vector.
Returns
Iterator pointing to the newly inserted element.

◆ insert() [2/3]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
template<std::input_iterator It>
iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::insert ( const_iterator  pos,
It  first,
It  last 
)

Inserts a copy of each element in [first, last) before pos.

Template Parameters
ItInput iterator type.
Parameters
posPosition to insert before.
firstIterator to the first element to insert.
lastIterator one past the last element to insert.
Returns
Iterator pointing to the first newly inserted element.

◆ insert() [3/3]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::insert ( const_iterator  pos,
T &&  value 
)

Inserts value before pos by move.

Parameters
posPosition to insert before.
valueValue to move-insert. Safe to pass a reference into this vector.
Returns
Iterator pointing to the newly inserted element.

◆ operator<=>()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
auto VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::operator<=> ( const Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents > &  other) const &
noexcept

Lexicographically compares two vectors.

Parameters
otherVector to compare against.
Returns
The three-way comparison result of the element sequences.

◆ operator=() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
Vector & VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::operator= ( const Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents > &  other)

Copy-assigns from other, replacing this vector's contents.

Parameters
otherVector to copy from.
Returns
Reference to *this.

Reuses existing capacity when sufficient; otherwise falls back to copy-and-swap for the strong exception guarantee.

◆ operator=() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
Vector & VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::operator= ( Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents > &&  other)
noexcept

Move-assigns from other, replacing this vector's contents.

Parameters
otherVector to move from, left empty afterward.
Returns
Reference to *this.

◆ operator==()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
bool VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::operator== ( const Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents > &  other) const &
noexcept

Compares two vectors for equality.

Parameters
otherVector to compare against.
Returns
true if both vectors have equal size and equal elements in order.

◆ operator[]() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_reference VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::operator[] ( std::size_t  index) const
noexcept

Returns a const reference to the element at index, without bounds checking.

Parameters
indexZero-based index of the element to access.
Returns
Const reference to the element at index.

◆ operator[]() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
reference VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::operator[] ( std::size_t  index)
noexcept

Returns a reference to the element at index, without bounds checking.

Parameters
indexZero-based index of the element to access.
Returns
Reference to the element at index.

◆ pop_back()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
void VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::pop_back ( )

Removes the last element. No-op if the vector is empty.

◆ push_back() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
void VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::push_back ( const T &  value)

Appends a copy of value to the end, growing capacity if needed.

Parameters
valueValue to append. Safe to pass a reference into this vector.

◆ push_back() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
void VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::push_back ( T &&  value)

Appends value to the end by move, growing capacity if needed.

Parameters
valueValue to move-append. Safe to pass a reference into this vector.

◆ rbegin() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_reverse_iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::rbegin ( ) const
noexcept

Returns a const reverse iterator to the last element.

◆ rbegin() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
reverse_iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::rbegin ( )
noexcept

Returns a reverse iterator to the last element.

◆ remove_if()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
template<typename Predicate >
requires std::predicate<Predicate, const T&>
std::size_t VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::remove_if ( Predicate  pred)

Removes all elements for which pred returns true.

Template Parameters
PredicateUnary predicate type invocable on const T&.
Parameters
predPredicate used to test each element.
Returns
The number of elements removed.

Relative order of retained elements is preserved.

◆ rend() [1/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
const_reverse_iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::rend ( ) const
noexcept

Returns a const reverse iterator one before the first element.

◆ rend() [2/2]

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
reverse_iterator VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::rend ( )
noexcept

Returns a reverse iterator one before the first element.

◆ reserve()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
void VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::reserve ( std::size_t  newCap)

Ensures capacity is at least newCap, reallocating if needed.

Parameters
newCapMinimum capacity to reserve. No-op if not greater than current capacity.

◆ shrink_to_fit()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
void VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::shrink_to_fit ( )

Reduces capacity to match the current size, reallocating if needed.

◆ size()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
std::size_t VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::size ( ) const
noexcept

Returns the number of elements currently stored.

◆ subscribe()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
template<typename F >
requires EnableEvents
&&Listener< F, Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents > > ListenerHandle VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::subscribe ( F &&  listeners)

Registers a listener to be notified of modification events.

Template Parameters
FCallable type satisfying the Listener concept.
Parameters
listenersCallable to invoke with (*this, EventData) on each modification.
Returns
A handle that can be passed to unsubscribe() to remove the listener.

Only callable when EnableEvents is true; a Vector with events disabled has no listener storage, so subscribing is a compile error rather than a silent no-op.

◆ swap()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
void VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::swap ( Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents > &  other)
noexcept

Exchanges the contents of two vectors, including allocators.

Parameters
otherVector to swap with.

◆ unsubscribe()

template<typename T , typename Allocator = std::allocator<T>, std::size_t GrowthNum = 2, std::size_t GrowthDen = 1, bool EnableEvents = false>
void VectorPro::Vector< T, Allocator, GrowthNum, GrowthDen, EnableEvents >::unsubscribe ( ListenerHandle  handle)

Removes a previously registered listener.

Parameters
handleHandle returned by subscribe(). No-op if out of range.

Only callable when EnableEvents is true.


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