PIVector doc

This commit is contained in:
Andrey
2022-04-12 10:43:07 +03:00
parent 7cd824f3ab
commit 486fdf3dcd

View File

@@ -1218,7 +1218,7 @@ public:
//! v.remove(1, 2);
//! piCout << v; // 1, 5
//! \endcode
//! \~\sa \a resize(), \a insert()
//! \~\sa \a resize(), \a insert(), \a removeOne(), \a removeAll(), \a removeWhere()
inline PIVector<T> & remove(size_t index, size_t count = 1) {
if (count == 0) return *this;
if (index + count >= piv_size) {
@@ -1291,17 +1291,36 @@ public:
return ret.reverse();
}
inline PIVector<T> & enlarge(llong piv_size, const T & e = T()) {
llong ns = size_s() + piv_size;
//! \~\brief
//! \~english Increases or decreases the size of the array by `add_size` elements.
//! \~russian Увеличивает или уменьшает размер массива на `add_size` элементов.
//! \~\details
//! \~english If `add_size > 0` then elements are added to the end of the array.
//! If `add_size < 0` then elements are removed from the end of the array.
//! If `add_size < 0` and there are fewer elements in the array than specified, then the array becomes empty.
//! \~russian Если `add_size > 0` то в конец массива добавляются элементы.
//! Если `add_size < 0` то с конца массива удаляются элементы.
//! Если `add_size < 0` и в массиве меньше элементов чем указано, то массив становится пустым.
//! \~\sa \a resize()
inline PIVector<T> & enlarge(llong add_size, const T & e = T()) {
llong ns = size_s() + add_size;
if (ns <= 0) clear();
else resize(size_t(ns), e);
return *this;
}
/*! \brief Remove no more than one element equal "v" and return reference to vector
* \details Example: \snippet picontainers.cpp PIVector::removeOne
* \sa \a remove(), \a removeAll()
*/
//! \brief
//! \~english Remove no more than one element equal "v" and return reference to vector
//! \~russian
//! \details
//! \~english
//! \~russian
//! \~\code
//! PIVector<int> v{3, 2, 5, 2, 7};
//! v.removeOne(2);
//! piCout << v; // 3, 5, 2, 7
//! \endcode
//! \~\sa \a remove(), \a removeAll(), \a removeWhere()
inline PIVector<T> & removeOne(const T & e) {
for (size_t i = 0; i < piv_size; ++i) {
if (piv_data[i] == e) {
@@ -1311,6 +1330,19 @@ public:
}
return *this;
}
//! \brief
//! \~english Remove no more than one element equal "v" and return reference to vector
//! \~russian
//! \details
//! \~english
//! \~russian
//! \~\code
//! PIVector<int> v{3, 2, 5, 2, 7};
//! v.removeAll(2);
//! piCout << v; // 3, 5, 7
//! \endcode
//! \~\sa \a remove(), \a removeOne(), \a removeWhere()
inline PIVector<T> & removeAll(const T & e) {
for (ssize_t i = 0; i < size_s(); ++i) {
if (piv_data[i] == e) {
@@ -1320,6 +1352,7 @@ public:
}
return *this;
}
inline PIVector<T> & removeWhere(std::function<bool(const T & e)> test) {
for (ssize_t i = 0; i < size_s(); ++i) {
if (test(piv_data[i])) {