Template Struct SharedVector¶
Defined in File slint_sharedvector.h
Struct Documentation¶
-
template<typename T>
struct SharedVector¶ SharedVector is a vector template class similar to std::vector that’s primarily used for passing data in and out of the Slint run-time library. It uses implicit-sharing to make creating copies cheap. Only when a function changes the vector’s data, a copy is is made.
Public Functions
-
inline SharedVector()¶
Creates a new, empty vector.
-
inline SharedVector(std::initializer_list<T> args)¶
Creates a new vector that holds all the elements of the given std::initializer_list args.
-
inline explicit SharedVector(size_t size)¶
Creates a vector of a given size, with default-constructed data.
-
inline explicit SharedVector(size_t size, const T &value)¶
Creates a vector of a given size, initialized with copies of the value.
-
template<class InputIt>
inline SharedVector(InputIt first, InputIt last)¶ Constructs the container with the contents of the range
[first, last)
.
-
inline SharedVector(const SharedVector &other)¶
Creates a new vector that is a copy of other.
-
inline ~SharedVector()¶
Destroys this vector. The underlying data is destroyed if no other vector references it.
-
inline SharedVector &operator=(const SharedVector &other)¶
Assigns the data of other to this vector and returns a reference to this vector.
-
inline SharedVector &operator=(SharedVector &&other)¶
Move-assign’s other to this vector and returns a reference to this vector.
-
inline const T *cend() const¶
Returns a const pointer that points past the last element of this vector. The pointer cannot be dereferenced, it can only be used for comparison.
-
inline const T *end() const¶
Returns a const pointer that points past the last element of this vector. The pointer cannot be dereferenced, it can only be used for comparison.
-
inline T *end()¶
Returns a pointer that points past the last element of this vector. The pointer cannot be dereferenced, it can only be used for comparison.
-
inline std::size_t size() const¶
Returns the number of elements in this vector.
-
inline bool empty() const¶
Returns true if there are no elements on this vector; false otherwise.
-
inline T &operator[](std::size_t index)¶
This indexing operator returns a reference to the th element of this vector.
-
inline const T &operator[](std::size_t index) const¶
This indexing operator returns a const reference to the th element of this vector.
-
inline void push_back(const T &value)¶
Appends the value as a new element to the end of this vector.
-
inline void clear()¶
Clears the vector and removes all elements. The capacity remains unaffected.
Friends
-
inline friend bool operator==(const SharedVector &a, const SharedVector &b)¶
Returns true if the vector a has the same number of elements as b and all the elements also compare equal; false otherwise.
-
inline SharedVector()¶