|
| 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.
|
|
PolymorphicObjectVector & | operator= (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.
|
|
|
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 > |
|
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.
|
|
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.
|
|
| 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.
|
|
Container | mContainer |
|
static const int | SIZE |
| Size of the vector at compile time. It will be -1 if the Vector has dynamic size.
|
|
static const int | SIZE = N |
| Size of the vector at compile time. It will be -1 if the Vector has dynamic size.
|
|
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
-
T | The base class of the polymorphic objects stored in the container. The class T must implement the Cloneable concept. |
N | the 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. |