Visual Computing Library
Loading...
Searching...
No Matches
vcl::PolymorphicObjectVector< T, N > Class Template Reference

The PolymorphicObjectVector class is a container that stores a collection of polymorphic objects, having a common base class T. More...

#include <vclib/space/core/vector/polymorphic_object_vector.h>

Inheritance diagram for vcl::PolymorphicObjectVector< T, N >:

Public Types

using ValueType = Base::ValueType
 
using ConstValueType = Base::ConstValueType
 
using Iterator = BaseVector::ConstIterator
 
using ConstIterator = Base::ConstIterator
 

Public Member Functions

 PolymorphicObjectVector (const PolymorphicObjectVector &other)
 Creates a Vector object with copied of the elements of the other Vector.
 
 PolymorphicObjectVector (PolymorphicObjectVector &&other) noexcept
 Move constructor.
 
 PolymorphicObjectVector (std::size_t size, const T &value)
 Creates a Vector object with the specified size.
 
template<typename ItType >
 PolymorphicObjectVector (ItType first, ItType last)
 Constructs the container with the contents of the range [first, last).
 
template<Range RangeType>
 PolymorphicObjectVector (RangeType &&rng)
 Constructs the container with the contents of the range rng.
 
ValueType at (uint i)
 Access the specified element with bounds checking.
 
ValueType atMod (int i)
 Access the specified element, computing first the module of the position w.r.t. the size of the container.
 
ValueType front ()
 Access the first element of the Vector.
 
ValueType back ()
 Access the last element of the Vector.
 
void set (uint i, const T &e)
 Set the value of the element at the specified position.
 
void set (Base::ConstIterator it, const T &e)
 Set the value of the element at the specified position.
 
template<Range Rng>
requires InputRange<Rng, T>
void set (Rng &&r)
 Set the elements of the Vector using the values from a range.
 
void fill (const T &e)
 Fill all elements of the Vector with clones of the specified value.
 
void resize (uint n, const T &v)
 Resize the Vector to the specified size.
 
void pushBack (const T &v)
 Add an element to the end of the Vector.
 
void pushBack (T &&v)
 Add an element to the end of the Vector.
 
void insert (uint i, const T &v)
 Insert an element at the specified position in the Vector.
 
void insert (uint i, T &&v)
 Insert an element at the specified position in the Vector.
 
void swap (PolymorphicObjectVector &other)
 Swaps the contents of the container with those of other.
 
ValueType operator[] (uint i)
 Returns a reference to the element at specified location i. No bounds checking is performed.
 
ValueType operator() (uint i)
 Returns a reference to the element at specified location i. No bounds checking is performed.
 
PolymorphicObjectVectoroperator= (PolymorphicObjectVector other)
 Assignment operator of the PolymorphicObjectVector.
 
Iterator begin ()
 Return an iterator pointing to the beginning of the Vector.
 
Iterator end ()
 Return an iterator pointing to the end of the Vector.
 
ConstValueType at (uint i) const
 
Reference at (uint i)
 Access the specified element with bounds checking.
 
ConstReference at (uint i) const
 Access the specified element with bounds checking.
 
ConstValueType atMod (uint i) const
 
Reference atMod (int i)
 Access the specified element, computing first the module of the position w.r.t. the size of the container.
 
ConstReference atMod (int i) const
 Access the specified element, computing first the module of the position w.r.t. the size of the container.
 
ConstValueType back () const
 
Reference back ()
 Access the last element of the Vector.
 
ConstReference back () const
 Access the last element of the Vector.
 
void clear ()
 Remove all elements from the Vector.
 
bool contains (const MakeConstPointerT< T > &e) const
 Check if the Vector contains the specified element.
 
ConstPointer data () const
 
Pointer data ()
 Returns a pointer to the underlying array serving as element storage. The pointer is such that range [data(), data() + size()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).
 
ConstPointer data () const
 Returns a const pointer to the underlying array serving as element storage. The pointer is such that range [data(), data() + size()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).
 
bool empty () const noexcept
 Returns whether the vector is empty (i.e. whether its size is 0).
 
void erase (uint i)
 Remove the element at the specified index from the Vector.
 
void fill (const T &e)
 Fill all elements of the Vector with the specified value.
 
ConstIterator find (const MakeConstPointer< T > &e) const
 
Iterator find (const MakeConstPointerT< T > &e)
 Find the first occurrence of the specified element in the Vector.
 
ConstIterator find (const MakeConstPointerT< T > &e) const
 Find the first occurrence of the specified element in the Vector.
 
ConstValueType front () const
 
Reference front ()
 Access the first element of the Vector.
 
ConstReference front () const
 Access the first element of the Vector.
 
uint indexOf (const MakeConstPointerT< T > &e) const
 Get the index of the first occurrence of the specified element in the Vector.
 
void insert (uint i, const T &v)
 Insert an element at the specified position in the Vector.
 
void insert (uint i, T &&v)
 Insert an element at the specified position in the Vector.
 
void pushBack (const T &v)
 Add an element to the end of the Vector.
 
void pushBack (T &&v)
 Add an element to the end of the Vector.
 
void resize (uint n, const T &v=T())
 Resize the Vector to the specified size.
 
void set (uint i, const T &e)
 Set the value of the element at the specified position.
 
void set (uint i, T &&e)
 Set the value of the element at the specified position.
 
void set (ConstIterator it, const T &e)
 Set the value of the element at the specified position.
 
void set (ConstIterator it, T &&e)
 Set the value of the element at the specified position.
 
template<Range Rng>
requires InputRange<Rng, T>
void set (Rng &&r)
 Set the elements of the Vector using the values from a range.
 
std::size_t size () const
 Returns the size of the container.
 
void swap (Vector &other)
 Swaps the contents of the container with those of other.
 
ConstIterator begin () const
 
Iterator begin ()
 Return an iterator pointing to the beginning of the Vector.
 
ConstIterator begin () const
 Return a const iterator pointing to the beginning of the Vector.
 
ConstIterator end () const
 
Iterator end ()
 Return an iterator pointing to the end of the Vector.
 
ConstIterator end () const
 Return a const iterator pointing to the end of the Vector.
 

Static Public Attributes

static const int SIZE
 Size of the vector at compile time. It will be -1 if the Vector has dynamic size.
 

Private Types

using Base = PointerVector< std::shared_ptr< T >, N >
 
using BaseVector = Base::Vector
 

Friends

void swap (PolymorphicObjectVector &a, PolymorphicObjectVector &b)
 
void swap (Vector &a, Vector &b)
 

Additional Inherited Members

- Protected Types inherited from vcl::PointerVector< T, N >
using ValueType = Base::ValueType
 
using ConstValueType = MakeConstPointerT< ValueType >
 
using Reference = Base::Reference
 
using ConstPointer = const ConstValueType *
 
using Pointer = Base::Pointer
 
using Iterator = Base::Iterator
 
using ConstIterator = ConstPointerIterator< typename Base::ConstIterator >
 
- Protected Types inherited from vcl::Vector< T, N >
using ValueType = Container::value_type
 The type of the elements stored in the Vector.
 
using ConstReference = Container::const_reference
 A const reference to the type of the elements stored in the Vector.
 
using Reference = Container::reference
 A reference to the type of the elements stored in the Vector.
 
using ConstPointer = Container::const_pointer
 A const pointer to the type of the elements stored in the Vector.
 
using Pointer = Container::pointer
 A pointer to the type of the elements stored in the Vector.
 
using Iterator = Container::iterator
 An iterator to the elements of the Vector.
 
using ConstIterator = Container::const_iterator
 A const iterator to the elements of the Vector.
 
- Protected Member Functions inherited from vcl::PointerVector< T, N >
ConstValueType at (uint i) const
 
ConstValueType atMod (uint i) const
 
ConstValueType front () const
 
ConstValueType back () const
 
ConstPointer data () const
 
ConstIterator find (const MakeConstPointer< T > &e) const
 
ConstValueType operator[] (uint i) const
 
ConstValueType operator() (uint i) const
 
ConstIterator begin () const
 
ConstIterator end () const
 
 Vector ()=default
 Creates an empty Vector object.
 
 Vector (std::size_t size, const T &value=T())
 Creates a Vector object with the specified size.
 
template<typename ItType >
 Vector (ItType first, ItType last)
 Constructs the container with the contents of the range [first, last).
 
template<Range RangeType>
 Vector (RangeType &&rng)
 Constructs the container with the contents of the range rng.
 
 Vector (std::initializer_list< T > list)
 Constructs the container with the contents of the initializer list list.
 
Reference at (uint i)
 Access the specified element with bounds checking.
 
ConstReference at (uint i) const
 Access the specified element with bounds checking.
 
Reference atMod (int i)
 Access the specified element, computing first the module of the position w.r.t. the size of the container.
 
ConstReference atMod (int i) const
 Access the specified element, computing first the module of the position w.r.t. the size of the container.
 
Reference back ()
 Access the last element of the Vector.
 
ConstReference back () const
 Access the last element of the Vector.
 
void clear ()
 Remove all elements from the Vector.
 
bool contains (const MakeConstPointerT< T > &e) const
 Check if the Vector contains the specified element.
 
Pointer data ()
 Returns a pointer to the underlying array serving as element storage. The pointer is such that range [data(), data() + size()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).
 
ConstPointer data () const
 Returns a const pointer to the underlying array serving as element storage. The pointer is such that range [data(), data() + size()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).
 
bool empty () const noexcept
 Returns whether the vector is empty (i.e. whether its size is 0).
 
void erase (uint i)
 Remove the element at the specified index from the Vector.
 
void fill (const T &e)
 Fill all elements of the Vector with the specified value.
 
Iterator find (const MakeConstPointerT< T > &e)
 Find the first occurrence of the specified element in the Vector.
 
ConstIterator find (const MakeConstPointerT< T > &e) const
 Find the first occurrence of the specified element in the Vector.
 
Reference front ()
 Access the first element of the Vector.
 
ConstReference front () const
 Access the first element of the Vector.
 
uint indexOf (const MakeConstPointerT< T > &e) const
 Get the index of the first occurrence of the specified element in the Vector.
 
void insert (uint i, const T &v)
 Insert an element at the specified position in the Vector.
 
void insert (uint i, T &&v)
 Insert an element at the specified position in the Vector.
 
void pushBack (const T &v)
 Add an element to the end of the Vector.
 
void pushBack (T &&v)
 Add an element to the end of the Vector.
 
void resize (uint n, const T &v=T())
 Resize the Vector to the specified size.
 
void set (uint i, const T &e)
 Set the value of the element at the specified position.
 
void set (uint i, T &&e)
 Set the value of the element at the specified position.
 
void set (ConstIterator it, const T &e)
 Set the value of the element at the specified position.
 
void set (ConstIterator it, T &&e)
 Set the value of the element at the specified position.
 
template<Range Rng>
requires InputRange<Rng, T>
void set (Rng &&r)
 Set the elements of the Vector using the values from a range.
 
std::size_t size () const
 Returns the size of the container.
 
void swap (Vector &other)
 Swaps the contents of the container with those of other.
 
Iterator begin ()
 Return an iterator pointing to the beginning of the Vector.
 
ConstIterator begin () const
 Return a const iterator pointing to the beginning of the Vector.
 
Iterator end ()
 Return an iterator pointing to the end of the Vector.
 
ConstIterator end () const
 Return a const iterator pointing to the end of the Vector.
 
- Protected Member Functions inherited from vcl::Vector< T, N >
 Vector ()=default
 Creates an empty Vector object.
 
 Vector (std::size_t size, const T &value=T())
 Creates a Vector object with the specified size.
 
template<typename ItType >
 Vector (ItType first, ItType last)
 Constructs the container with the contents of the range [first, last).
 
template<Range RangeType>
 Vector (RangeType &&rng)
 Constructs the container with the contents of the range rng.
 
 Vector (std::initializer_list< T > list)
 Constructs the container with the contents of the initializer list list.
 
std::size_t size () const
 Returns the size of the container.
 
Reference at (uint i)
 Access the specified element with bounds checking.
 
ConstReference at (uint i) const
 Access the specified element with bounds checking.
 
Reference atMod (int i)
 Access the specified element, computing first the module of the position w.r.t. the size of the container.
 
ConstReference atMod (int i) const
 Access the specified element, computing first the module of the position w.r.t. the size of the container.
 
Reference front ()
 Access the first element of the Vector.
 
ConstReference front () const
 Access the first element of the Vector.
 
Reference back ()
 Access the last element of the Vector.
 
ConstReference back () const
 Access the last element of the Vector.
 
Pointer data ()
 Returns a pointer to the underlying array serving as element storage. The pointer is such that range [data(), data() + size()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).
 
ConstPointer data () const
 Returns a const pointer to the underlying array serving as element storage. The pointer is such that range [data(), data() + size()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).
 
void set (uint i, const T &e)
 Set the value of the element at the specified position.
 
void set (uint i, T &&e)
 Set the value of the element at the specified position.
 
void set (ConstIterator it, const T &e)
 Set the value of the element at the specified position.
 
void set (ConstIterator it, T &&e)
 Set the value of the element at the specified position.
 
template<Range Rng>
requires InputRange<Rng, T>
void set (Rng &&r)
 Set the elements of the Vector using the values from a range.
 
void fill (const T &e)
 Fill all elements of the Vector with the specified value.
 
bool contains (const MakeConstPointerT< T > &e) const
 Check if the Vector contains the specified element.
 
Iterator find (const MakeConstPointerT< T > &e)
 Find the first occurrence of the specified element in the Vector.
 
ConstIterator find (const MakeConstPointerT< T > &e) const
 Find the first occurrence of the specified element in the Vector.
 
uint indexOf (const MakeConstPointerT< T > &e) const
 Get the index of the first occurrence of the specified element in the Vector.
 
void swap (Vector &other)
 Swaps the contents of the container with those of other.
 
void resize (uint n, const T &v=T())
 Resize the Vector to the specified size.
 
void pushBack (const T &v)
 Add an element to the end of the Vector.
 
void pushBack (T &&v)
 Add an element to the end of the Vector.
 
void insert (uint i, const T &v)
 Insert an element at the specified position in the Vector.
 
void insert (uint i, T &&v)
 Insert an element at the specified position in the Vector.
 
template<typename... Args>
requires (N < 0)
void emplace (uint i, Args &&... args)
 Insert an element at the specified position in the Vector.
 
bool empty () const noexcept
 Returns whether the vector is empty (i.e. whether its size is 0).
 
void erase (uint i)
 Remove the element at the specified index from the Vector.
 
void clear ()
 Remove all elements from the Vector.
 
void serialize (std::ostream &os) const
 
void deserialize (std::istream &is)
 
Reference operator[] (uint i)
 Returns a reference to the element at specified location i. No bounds checking is performed.
 
ConstReference operator[] (uint i) const
 Returns a const reference to the element at specified location i. No bounds checking is performed.
 
Reference operator() (uint i)
 Returns a reference to the element at specified location i. No bounds checking is performed.
 
ConstReference operator() (uint i) const
 Returns a const reference to the element at specified location i. No bounds checking is performed.
 
Iterator begin ()
 Return an iterator pointing to the beginning of the Vector.
 
Iterator end ()
 Return an iterator pointing to the end of the Vector.
 
ConstIterator begin () const
 Return a const iterator pointing to the beginning of the Vector.
 
ConstIterator end () const
 Return a const iterator pointing to the end of the Vector.
 
- Protected Attributes inherited from vcl::Vector< T, N >
Container mContainer
 
- Static Protected Attributes inherited from vcl::PointerVector< T, N >
static const int SIZE
 Size of the vector at compile time. It will be -1 if the Vector has dynamic size.
 
- Static Protected Attributes inherited from vcl::Vector< T, N >
static const int SIZE = N
 Size of the vector at compile time. It will be -1 if the Vector has dynamic size.
 

Detailed Description

template<Cloneable T, int N = -1>
class vcl::PolymorphicObjectVector< T, N >

The PolymorphicObjectVector class is a container that stores a collection of polymorphic objects, having a common base class T.

The PolymorphicObjectVector class is a container that stores a collection of polymorphic objects, having a common base class T. The class is designed to work with objects that are cloneable, i.e., that implement the Cloneable concept (they must implement a member function clone() that returns a shared pointer that points to a newly created object).

The container stores the objects as shared pointers to the base class. All the member functions of this class that take a value of type T as argument will clone the object before storing it in the container. This way, the container will own a copy of the object, and the original object will not be modified (as it is made normally on std::vector). To avoid cloning, you can pass a shared pointer to the object.

The size of the container can be either fixed or dynamic, depending on the value of the template parameter N. If N is greater than or equal to zero, the container will have a fixed size of N elements, and it will use an array to store the elements. If N is less than zero, the container will have a dynamic size, and it will use a vector to store the elements.

Template Parameters
TThe base class of the polymorphic objects stored in the container. The class T must implement the Cloneable concept.
Nthe size of the container. If N is greater than or equal to zero, the container will have a fixed size of N elements, and it will use an array to store the elements. If N is less than zero, the container will have a dynamic size, and it will use a vector to store the elements.

Constructor & Destructor Documentation

◆ PolymorphicObjectVector() [1/5]

template<Cloneable T, int N = -1>
vcl::PolymorphicObjectVector< T, N >::PolymorphicObjectVector ( const PolymorphicObjectVector< T, N > &  other)
inline

Creates a Vector object with copied of the elements of the other Vector.

If the container is dynamic, its size is set to the size of the other Vector. When the container is static, the size is N and the elements are initialized with the same elements as the other Vector.

Parameters
[in]otherThe other Vector to copy.

◆ PolymorphicObjectVector() [2/5]

template<Cloneable T, int N = -1>
vcl::PolymorphicObjectVector< T, N >::PolymorphicObjectVector ( PolymorphicObjectVector< T, N > &&  other)
inlinenoexcept

Move constructor.

Parameters
[in]otherAnother PolymorphicObjectVector container of the same type.

◆ PolymorphicObjectVector() [3/5]

template<Cloneable T, int N = -1>
vcl::PolymorphicObjectVector< T, N >::PolymorphicObjectVector ( std::size_t  size,
const T &  value 
)
inline

Creates a Vector object with the specified size.

If the container is dynamic, its size is set to size. When the container is static, the given size must be equal to N. The elements are initialized with their empty constructor if the argument value is not specified. Otherwise, the elements are initialized with the given value.

Exceptions
WrongSizeExceptionif the given size is not equal to N and the container is static.
Parameters
[in]sizethe size of the container.
[in]valuethe value to initialize the elements with.

◆ PolymorphicObjectVector() [4/5]

template<Cloneable T, int N = -1>
template<typename ItType >
vcl::PolymorphicObjectVector< T, N >::PolymorphicObjectVector ( ItType  first,
ItType  last 
)
inline

Constructs the container with the contents of the range [first, last).

If the container is dynamic, the size of the container is determined by the number of elements in the range [first, last). If the container is static, the elements are initialized with the contents of the first N elements of the range [first, last). If the range contains less than N elements, the remaining elements are initialized with their empty constructor.

Template Parameters
ItTypeThe type of the iterators used to access the elements in the range.
Parameters
[in]firstThe beginning of the range.
[in]lastThe end of the range.

◆ PolymorphicObjectVector() [5/5]

template<Cloneable T, int N = -1>
template<Range RangeType>
vcl::PolymorphicObjectVector< T, N >::PolymorphicObjectVector ( RangeType &&  rng)
inline

Constructs the container with the contents of the range rng.

If the container is dynamic, the size of the container is determined by the number of elements in the input range. If the container is static, the elements are initialized with the contents of the first N elements of the range. If the range contains less than N elements, the remaining elements are initialized with their empty constructor.

Template Parameters
RangeTypeThe type of the range used to access the elements in the range. It must satisfy the vcl::Range concept.
Parameters
[in]rnga range of T elements.

Member Function Documentation

◆ at() [1/3]

template<Cloneable T, int N = -1>
Reference vcl::Vector< T, N >::at ( uint  i)
inline

Access the specified element with bounds checking.

Returns a reference to the element at position i in the Vector, with bounds checking. If i is not within the range of valid indices for the Vector, an std::out_of_range exception is thrown.

Parameters
[in]iThe position of the element.
Returns
A reference to the element at position i.
Exceptions
std::out_of_rangeIf i is not within the range of valid indices for the Vector.

◆ at() [2/3]

template<Cloneable T, int N = -1>
ValueType vcl::PolymorphicObjectVector< T, N >::at ( uint  i)
inline

Access the specified element with bounds checking.

Returns a reference to the element at position i in the Vector, with bounds checking. If i is not within the range of valid indices for the Vector, an std::out_of_range exception is thrown.

Parameters
[in]iThe position of the element.
Returns
A reference to the element at position i.
Exceptions
std::out_of_rangeIf i is not within the range of valid indices for the Vector.

◆ at() [3/3]

template<Cloneable T, int N = -1>
ConstReference vcl::Vector< T, N >::at ( uint  i) const
inline

Access the specified element with bounds checking.

Returns a const reference to the element at position i in the Vector, with bounds checking. If i is not within the range of valid indices for the Vector, an std::out_of_range exception is thrown.

Parameters
[in]iThe position of the element.
Returns
A const reference to the element at position i.
Exceptions
std::out_of_rangeIf i is not within the range of valid indices for the Vector.

◆ atMod() [1/3]

template<Cloneable T, int N = -1>
Reference vcl::Vector< T, N >::atMod ( int  i)
inline

Access the specified element, computing first the module of the position w.r.t. the size of the container.

Takes into account negative indices: atMod(-1) will access to the last element of the container.

Parameters
[in]iThe position of the element.
Returns
A reference to the element at position i % size().

◆ atMod() [2/3]

template<Cloneable T, int N = -1>
ValueType vcl::PolymorphicObjectVector< T, N >::atMod ( int  i)
inline

Access the specified element, computing first the module of the position w.r.t. the size of the container.

Takes into account negative indices: atMod(-1) will access to the last element of the container.

Parameters
[in]iThe position of the element.
Returns
A const reference to the element at position i % size().

◆ atMod() [3/3]

template<Cloneable T, int N = -1>
ConstReference vcl::Vector< T, N >::atMod ( int  i) const
inline

Access the specified element, computing first the module of the position w.r.t. the size of the container.

Takes into account negative indices: atMod(-1) will access to the last element of the container.

Parameters
[in]iThe position of the element.
Returns
A const reference to the element at position i % size().

◆ back() [1/3]

template<Cloneable T, int N = -1>
Reference vcl::Vector< T, N >::back ( )
inline

Access the last element of the Vector.

Returns a reference to the last element of the Vector. If the Vector is empty, the behavior is undefined.

Returns
A reference to the last element.

◆ back() [2/3]

template<Cloneable T, int N = -1>
ValueType vcl::PolymorphicObjectVector< T, N >::back ( )
inline

Access the last element of the Vector.

Returns a reference to the last element of the Vector. If the Vector is empty, the behavior is undefined.

Returns
A reference to the last element.

◆ back() [3/3]

template<Cloneable T, int N = -1>
ConstReference vcl::Vector< T, N >::back ( ) const
inline

Access the last element of the Vector.

Returns a const reference to the last element of the Vector. If the Vector is empty, the behavior is undefined.

Returns
A const reference to the last element.

◆ begin() [1/3]

template<Cloneable T, int N = -1>
Iterator vcl::Vector< T, N >::begin ( )
inline

Return an iterator pointing to the beginning of the Vector.

Returns
An iterator pointing to the beginning of the Vector.

◆ begin() [2/3]

template<Cloneable T, int N = -1>
Iterator vcl::PolymorphicObjectVector< T, N >::begin ( )
inline

Return an iterator pointing to the beginning of the Vector.

Returns
An iterator pointing to the beginning of the Vector.

◆ begin() [3/3]

template<Cloneable T, int N = -1>
ConstIterator vcl::Vector< T, N >::begin ( ) const
inline

Return a const iterator pointing to the beginning of the Vector.

Returns
A const iterator pointing to the beginning of the Vector.

◆ clear()

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::clear ( )
inline

Remove all elements from the Vector.

Removes all elements from the Vector by calling the clear() member function of the underlying std::vector. This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

◆ contains()

template<Cloneable T, int N = -1>
bool vcl::Vector< T, N >::contains ( const MakeConstPointerT< T > &  e) const
inline

Check if the Vector contains the specified element.

Checks if the Vector contains the element specified by e, using the std::find() algorithm.

Parameters
[in]eThe element to search for in the Vector.
Returns
true if the element is found in the Vector, false otherwise.

◆ data() [1/2]

template<Cloneable T, int N = -1>
Pointer vcl::Vector< T, N >::data ( )
inline

Returns a pointer to the underlying array serving as element storage. The pointer is such that range [data(), data() + size()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).

Returns
A pointer to the underlying element storage. For non-empty containers, the returned pointer compares equal to the address of the first element.

◆ data() [2/2]

template<Cloneable T, int N = -1>
ConstPointer vcl::Vector< T, N >::data ( ) const
inline

Returns a const pointer to the underlying array serving as element storage. The pointer is such that range [data(), data() + size()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).

Returns
A const pointer to the underlying element storage. For non-empty containers, the returned pointer compares equal to the address of the first element.

◆ empty()

template<Cloneable T, int N = -1>
bool vcl::Vector< T, N >::empty ( ) const
inlinenoexcept

Returns whether the vector is empty (i.e. whether its size is 0).

Returns
true if the container size is 0, false otherwise.

◆ end() [1/3]

template<Cloneable T, int N = -1>
Iterator vcl::Vector< T, N >::end ( )
inline

Return an iterator pointing to the end of the Vector.

Returns
An iterator pointing to the end of the Vector.

◆ end() [2/3]

template<Cloneable T, int N = -1>
Iterator vcl::PolymorphicObjectVector< T, N >::end ( )
inline

Return an iterator pointing to the end of the Vector.

Returns
An iterator pointing to the end of the Vector.

◆ end() [3/3]

template<Cloneable T, int N = -1>
ConstIterator vcl::Vector< T, N >::end ( ) const
inline

Return a const iterator pointing to the end of the Vector.

Returns
A const iterator pointing to the end of the Vector.

◆ erase()

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::erase ( uint  i)
inline

Remove the element at the specified index from the Vector.

Removes the element at the position specified by i in the Vector by calling the erase() member function of the underlying std::vector. This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

Parameters
[in]iThe index of the element to remove from the Vector.

◆ fill() [1/2]

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::fill ( const T &  e)
inline

Fill all elements of the Vector with the specified value.

Sets all elements of the Vector to the value specified by e, using the std::fill() algorithm.

Parameters
[in]eThe value to fill the Vector with.

◆ fill() [2/2]

template<Cloneable T, int N = -1>
void vcl::PolymorphicObjectVector< T, N >::fill ( const T &  e)
inline

Fill all elements of the Vector with clones of the specified value.

Sets all elements of the Vector to clones of the value specified by e, using the std::fill() algorithm.

Parameters
[in]eThe value to fill the Vector with.

◆ find() [1/2]

template<Cloneable T, int N = -1>
Iterator vcl::Vector< T, N >::find ( const MakeConstPointerT< T > &  e)
inline

Find the first occurrence of the specified element in the Vector.

Finds the first occurrence of the element specified by e in the Vector, using the std::find() algorithm.

Parameters
[in]eThe element to search for in the Vector.
Returns
An iterator to the first occurrence of the element in the Vector, or end() if the element is not found.

◆ find() [2/2]

template<Cloneable T, int N = -1>
ConstIterator vcl::Vector< T, N >::find ( const MakeConstPointerT< T > &  e) const
inline

Find the first occurrence of the specified element in the Vector.

Finds the first occurrence of the element specified by e in the Vector, using the std::find() algorithm.

Parameters
[in]eThe element to search for in the Vector.
Returns
A const iterator to the first occurrence of the element in the Vector, or end() if the element is not found.

◆ front() [1/3]

template<Cloneable T, int N = -1>
Reference vcl::Vector< T, N >::front ( )
inline

Access the first element of the Vector.

Returns a reference to the first element of the Vector. If the Vector is empty, the behavior is undefined.

Returns
A reference to the first element.

◆ front() [2/3]

template<Cloneable T, int N = -1>
ValueType vcl::PolymorphicObjectVector< T, N >::front ( )
inline

Access the first element of the Vector.

Returns a reference to the first element of the Vector. If the Vector is empty, the behavior is undefined.

Returns
A reference to the first element.

◆ front() [3/3]

template<Cloneable T, int N = -1>
ConstReference vcl::Vector< T, N >::front ( ) const
inline

Access the first element of the Vector.

Returns a const reference to the first element of the Vector. If the Vector is empty, the behavior is undefined.

Returns
A const reference to the first element.

◆ indexOf()

template<Cloneable T, int N = -1>
uint vcl::Vector< T, N >::indexOf ( const MakeConstPointerT< T > &  e) const
inline

Get the index of the first occurrence of the specified element in the Vector.

Finds the first occurrence of the element specified by e in the Vector, using the std::find() algorithm, and returns its index. If the element is not found in the Vector, the member function returns UINT_NULL.

Parameters
[in]eThe element to search for in the Vector.
Returns
The index of the first occurrence of the element in the Vector, or UINT_NULL if the element is not found.

◆ insert() [1/4]

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::insert ( uint  i,
const T &  v 
)
inline

Insert an element at the specified position in the Vector.

Inserts the element v at the position specified by i in the Vector by calling the insert() member function of the underlying std::vector. This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

Parameters
[in]iThe index at which to insert the element.
[in]vThe value to insert into the Vector.

◆ insert() [2/4]

template<Cloneable T, int N = -1>
void vcl::PolymorphicObjectVector< T, N >::insert ( uint  i,
const T &  v 
)
inline

Insert an element at the specified position in the Vector.

Inserts the clone of the element v at the position specified by i in the Vector by calling the insert() member function of the underlying std::vector.

This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

Parameters
[in]iThe index at which to insert the element.
[in]vThe value to insert into the Vector.

◆ insert() [3/4]

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::insert ( uint  i,
T &&  v 
)
inline

Insert an element at the specified position in the Vector.

Inserts the element v at the position specified by i in the Vector by calling the insert() member function of the underlying std::vector. This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

Parameters
[in]iThe index at which to insert the element.
[in]vThe value to insert into the Vector.

◆ insert() [4/4]

template<Cloneable T, int N = -1>
void vcl::PolymorphicObjectVector< T, N >::insert ( uint  i,
T &&  v 
)
inline

Insert an element at the specified position in the Vector.

Inserts the clone of the element v at the position specified by i in the Vector by calling the insert() member function of the underlying std::vector. If the Cloneable type T implements the move clone, the element is moved into the vector.

This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

Parameters
[in]iThe index at which to insert the element.
[in]vThe value to insert into the Vector.

◆ operator()()

template<Cloneable T, int N = -1>
ValueType vcl::PolymorphicObjectVector< T, N >::operator() ( uint  i)
inline

Returns a reference to the element at specified location i. No bounds checking is performed.

Parameters
[in]iPosition of the element to return
Returns
A reference to the requested element.

◆ operator=()

template<Cloneable T, int N = -1>
PolymorphicObjectVector & vcl::PolymorphicObjectVector< T, N >::operator= ( PolymorphicObjectVector< T, N >  other)
inline

Assignment operator of the PolymorphicObjectVector.

Parameters
[in]otherAnother PolymorphicObjectVector container of the same type.
Returns
A reference to this.

◆ operator[]()

template<Cloneable T, int N = -1>
ValueType vcl::PolymorphicObjectVector< T, N >::operator[] ( uint  i)
inline

Returns a reference to the element at specified location i. No bounds checking is performed.

Parameters
[in]iPosition of the element to return
Returns
A reference to the requested element.

◆ pushBack() [1/4]

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::pushBack ( const T &  v)
inline

Add an element to the end of the Vector.

Adds the element v to the end of the Vector by calling the push_back() member function of the underlying std::vector. This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

Parameters
[in]vThe value to add to the end of the Vector.

◆ pushBack() [2/4]

template<Cloneable T, int N = -1>
void vcl::PolymorphicObjectVector< T, N >::pushBack ( const T &  v)
inline

Add an element to the end of the Vector.

Adds the clone of the element v to the end of the Vector by calling the push_back() member function of the underlying std::vector.

This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

Parameters
[in]vThe value to add to the end of the Vector.

◆ pushBack() [3/4]

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::pushBack ( T &&  v)
inline

Add an element to the end of the Vector.

Moves the element v to the end of the Vector by calling the push_back() member function of the underlying std::vector. This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

Parameters
[in]vThe value to add to the end of the Vector.

◆ pushBack() [4/4]

template<Cloneable T, int N = -1>
void vcl::PolymorphicObjectVector< T, N >::pushBack ( T &&  v)
inline

Add an element to the end of the Vector.

Adds the clone of the element v to the end of the Vector by calling the push_back() member function of the underlying std::vector. If the Cloneable type T implements the move clone, the element is moved into the vector.

This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

Parameters
[in]vThe value to add to the end of the Vector.

◆ resize() [1/2]

template<Cloneable T, int N = -1>
void vcl::PolymorphicObjectVector< T, N >::resize ( uint  n,
const T &  v 
)
inline

Resize the Vector to the specified size.

Resizes the Vector to the specified size n by resizing the underlying std::vector. If the new size is greater than the current size, the new elements are initialized with a clone of the value v.

This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

Parameters
[in]nThe new size of the Vector.
[in]vThe value to use to fill the new elements of the Vector.

◆ resize() [2/2]

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::resize ( uint  n,
const T &  v = T() 
)
inline

Resize the Vector to the specified size.

Resizes the Vector to the specified size n by resizing the underlying std::vector. This member function is only available if the size of the Vector is not known at compile-time, as specified by the concept requirement requires (N < 0).

Parameters
[in]nThe new size of the Vector.
[in]vThe value to use to fill the new elements of the Vector.

◆ set() [1/8]

template<Cloneable T, int N = -1>
void vcl::PolymorphicObjectVector< T, N >::set ( Base::ConstIterator  it,
const T &  e 
)
inline

Set the value of the element at the specified position.

Sets the value of the element at position it in the Vector to the specified value e.

Parameters
[in]itThe iterator pointing to the position of the element.
[in]eThe new value of the element.

◆ set() [2/8]

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::set ( ConstIterator  it,
const T &  e 
)
inline

Set the value of the element at the specified position.

Sets the value of the element at position it in the Vector to the specified value e.

Parameters
[in]itThe iterator pointing to the position of the element.
[in]eThe new value of the element.

◆ set() [3/8]

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::set ( ConstIterator  it,
T &&  e 
)
inline

Set the value of the element at the specified position.

Sets the value of the element at position it in the Vector by moving the specified value e.

Parameters
[in]itThe iterator pointing to the position of the element.
[in]eThe new value of the element.

◆ set() [4/8]

template<Cloneable T, int N = -1>
template<Range Rng>
requires InputRange<Rng, T>
void vcl::Vector< T, N >::set ( Rng &&  r)
inline

Set the elements of the Vector using the values from a range.

Sets the elements of the Vector to the values from the range r. If the size of the Vector is known at compile-time and is not negative, the first N elements from the range r (or all of them, if they are less than N) are copied into the Vector using std::copy_n(). If the size of the Vector is negative or not known at compile-time, the elements of the Vector are set to the values from the range r by constructing a new std::vector from the range r.

Template Parameters
RngThe type of the range, it must satisfy the Range concept and the value type of the range must be convertible to T.
Parameters
[in]rThe range of values to set the elements of the Vector to.

◆ set() [5/8]

template<Cloneable T, int N = -1>
template<Range Rng>
requires InputRange<Rng, T>
void vcl::PolymorphicObjectVector< T, N >::set ( Rng &&  r)
inline

Set the elements of the Vector using the values from a range.

Sets the elements of the Vector to the values from the range r. If the size of the Vector is known at compile-time and is not negative, the first N elements from the range r (or all of them, if they are less than N) are copied into the Vector using std::copy_n(). If the size of the Vector is negative or not known at compile-time, the elements of the Vector are set to the values from the range r by constructing a new std::vector from the range r.

Template Parameters
RngThe type of the range, it must satisfy the Range concept and the value type of the range must be convertible to T.
Parameters
[in]rThe range of values to set the elements of the Vector to.

◆ set() [6/8]

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::set ( uint  i,
const T &  e 
)
inline

Set the value of the element at the specified position.

Sets the value of the element at position i in the Vector to the specified value e.

Parameters
[in]iThe position of the element.
[in]eThe new value of the element.

◆ set() [7/8]

template<Cloneable T, int N = -1>
void vcl::PolymorphicObjectVector< T, N >::set ( uint  i,
const T &  e 
)
inline

Set the value of the element at the specified position.

Sets the value of the element at position i in the Vector to the specified value e.

Parameters
[in]iThe position of the element.
[in]eThe new value of the element.

◆ set() [8/8]

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::set ( uint  i,
T &&  e 
)
inline

Set the value of the element at the specified position.

Sets the value of the element at position i in the Vector by moving the specified value e.

Parameters
[in]iThe position of the element.
[in]eThe new value of the element.

◆ size()

template<Cloneable T, int N = -1>
std::size_t vcl::Vector< T, N >::size ( ) const
inline

Returns the size of the container.

If the container is static, the size is N. If the container is dynamic, the size is determined by the number of elements currently stored.

Returns
The size of the container.

◆ swap() [1/2]

template<Cloneable T, int N = -1>
void vcl::PolymorphicObjectVector< T, N >::swap ( PolymorphicObjectVector< T, N > &  other)
inline

Swaps the contents of the container with those of other.

Parameters
[in]otherAnother PolymorphicObjectVector container of the same type.

◆ swap() [2/2]

template<Cloneable T, int N = -1>
void vcl::Vector< T, N >::swap ( Vector other)
inline

Swaps the contents of the container with those of other.

Parameters
[in]otherAnother Vector container of the same type.

Friends And Related Symbol Documentation

◆ swap [1/2]

template<Cloneable T, int N = -1>
void swap ( PolymorphicObjectVector< T, N > &  a,
PolymorphicObjectVector< T, N > &  b 
)
friend

Specializes the swap function to allow the swapping of two PolymorphicObjectVector objects.

Swaps the content of the two PolymorphicObjectVector objects. Calls a.swap(b).

Parameters
[in]aThe first PolymorphicObjectVector object.
[in]bThe second PolymorphicObjectVector object.

◆ swap [2/2]

template<Cloneable T, int N = -1>
void swap ( Vector a,
Vector b 
)
friend

Specializes the swap function to allow the swapping of two Vector objects.

Swaps the content of the two Vector objects. Calls a.swap(b).

Parameters
[in]aThe first Vector object.
[in]bThe second Vector object.

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