diff --git a/libs/main/containers/pivector.h b/libs/main/containers/pivector.h index f630b1ee..ab179472 100644 --- a/libs/main/containers/pivector.h +++ b/libs/main/containers/pivector.h @@ -1433,11 +1433,15 @@ public: //! \~english Appends the given element `e` to the end of the array. //! \~russian Добавляет элемент `e` в конец массива. //! \~\details - //! \~english If the new size() is greater than capacity() + //! \~english If size() is less than capacity(), which is most often + //! then the addition will be very fast, and does not depend on the size of the array. + //! If the new size() is greater than capacity() //! then all iterators and references //! (including the past-the-end iterator) are invalidated. //! Otherwise only the past-the-end iterator is invalidated. - //! \~russian Если новый size() больше, чем capacity(), + //! \~russian Если size() меньше capacity(), что чаше всего, + //! то добавление будет очень быстрым, и не зависит от размера массива. + //! Если новый size() больше, чем capacity(), //! то все итераторы и указатели становятся нерабочими. //! В противном случае, все, кроме итераторов указывающих на конец массива, //! остаются в рабочем состоянии. @@ -1511,11 +1515,15 @@ public: //! \~english Appends the given element `e` to the end of the array. //! \~russian Добавляет элемент `e` в конец массива. //! \~\details - //! \~english If the new size() is greater than capacity() + //! \~english If size() is less than capacity(), which is most often + //! then the addition will be very fast, and does not depend on the size of the array. + //! If the new size() is greater than capacity() //! then all iterators and references //! (including the past-the-end iterator) are invalidated. //! Otherwise only the past-the-end iterator is invalidated. - //! \~russian Если новый size() больше, чем capacity(), + //! \~russian Если size() меньше capacity(), что чаше всего, + //! то добавление будет очень быстрым, и не зависит от размера массива. + //! Если новый size() больше, чем capacity(), //! то все итераторы и указатели становятся нерабочими. //! В противном случае, все, кроме итераторов указывающих на конец массива, //! остаются в рабочем состоянии. @@ -1556,6 +1564,11 @@ public: //! \~\details //! \~english Overloaded function. //! \~russian Перегруженая функция. + //! \~\code + //! PIVector v{1, 2, 3}; + //! v.append(PIVector{4, 5}); + //! piCout << v; // 1, 2, 3, 4, 5 + //! \endcode //! \~\sa \a append() inline PIVector & append(const PIVector & v) {return push_back(v);} @@ -1595,11 +1608,97 @@ public: //! \~\sa \a append() inline PIVector & operator <<(const PIVector & v) {return push_back(v);} - inline PIVector & push_front(const T & e) {insert(0, e); return *this;} - inline PIVector & push_front(T && e) {insert(0, std::move(e)); return *this;} - inline PIVector & push_front(const PIVector & v) {insert(0, v); return *this;} + //! \brief + //! \~english Appends the given element `e` to the begin of the array. + //! \~russian Добавляет элемент `e` в начало массива. + //! \~\details + //! \~english Adding an element to the beginning takes longer than to the end. + //! This time is directly proportional to the size of the array. + //! All iterators and references are invalidated. + //! \~russian Добавление элемента в начало выполняется дольше чем в конец. + //! Это время прямопропорционально размеру массива. + //! При добавлении элемента все итераторы и указатели становятся нерабочими. + //! \~\code + //! PIVector v{1, 2, 3}; + //! v.push_front(4); + //! v.push_front(5); + //! piCout << v; // 5, 4, 1, 2, 3 + //! \endcode + //! \~\sa \a push_back(), \a append(), \a prepend(), \a insert() + inline PIVector & push_front(const T & e) { + insert(0, e); + return *this; + } + + //! \brief + //! \~english Appends the given element `e` to the begin of the array. + //! \~russian Добавляет элемент `e` в начало массива. + //! \~\details + //! \~english Overloaded function. + //! \~russian Перегруженая функция. + //! \~\sa \a push_front() + inline PIVector & push_front(T && e) { + insert(0, std::move(e)); + return *this; + } + + //! \brief + //! \~english Appends the given array `v` to the begin of the array. + //! \~russian Добавляет массив `v` в начало массива. + //! \~\details + //! \~english Overloaded function. + //! \~russian Перегруженая функция. + //! \~\code + //! PIVector v{1, 2, 3}; + //! v.push_front(PIVector{4, 5}); + //! piCout << v; // 4, 5, 1, 2, 3 + //! \endcode + //! \~\sa \a push_front() + inline PIVector & push_front(const PIVector & v) { + insert(0, v); + return *this; + } + + //! \brief + //! \~english Appends the given element `e` to the begin of the array. + //! \~russian Добавляет элемент `e` в начало массива. + //! \~\details + //! \~english Adding an element to the beginning takes longer than to the end. + //! This time is directly proportional to the size of the array. + //! All iterators and references are invalidated. + //! \~russian Добавление элемента в начало выполняется дольше чем в конец. + //! Это время прямопропорционально размеру массива. + //! При добавлении элемента все итераторы и указатели становятся нерабочими. + //! \~\code + //! PIVector v{1, 2, 3}; + //! v.prepend(4); + //! v.prepend(5); + //! piCout << v; // 5, 4, 1, 2, 3 + //! \endcode + //! \~\sa \a append(), \a push_back(), \a push_front(), \a insert() inline PIVector & prepend(const T & e) {return push_front(e);} + + //! \brief + //! \~english Appends the given element `e` to the begin of the array. + //! \~russian Добавляет элемент `e` в начало массива. + //! \~\details + //! \~english Overloaded function. + //! \~russian Перегруженая функция. + //! \~\sa \a prepend() inline PIVector & prepend(T && e) {return push_front(std::move(e));} + + //! \brief + //! \~english Appends the given array `v` to the begin of the array. + //! \~russian Добавляет массив `v` в начало массива. + //! \~\details + //! \~english Overloaded function. + //! \~russian Перегруженая функция. + //! \~\code + //! PIVector v{1, 2, 3}; + //! v.prepend(PIVector{4, 5}); + //! piCout << v; // 4, 5, 1, 2, 3 + //! \endcode + //! \~\sa \a prepend() inline PIVector & prepend(const PIVector & v) {return push_front(v);} inline PIVector & pop_back() { @@ -1613,8 +1712,16 @@ public: return *this; } - inline T take_back() {T e(back()); pop_back(); return e;} - inline T take_front() {T e(front()); pop_front(); return e;} + inline T take_back() { + T e(back()); + pop_back(); + return e; + } + inline T take_front() { + T e(front()); + pop_front(); + return e; + } template inline PIVector toType() const { @@ -1825,6 +1932,8 @@ private: #ifdef PIP_STD_IOSTREAM +//! \~english Output operator to [std::ostream](https://en.cppreference.com/w/cpp/io/basic_ostream). +//! \~russian Оператор вывода в [std::ostream](https://ru.cppreference.com/w/cpp/io/basic_ostream). template inline std::ostream & operator <<(std::ostream & s, const PIVector & v) { s << "{"; @@ -1837,6 +1946,9 @@ inline std::ostream & operator <<(std::ostream & s, const PIVector & v) { } #endif +//! \relatesalso PICout +//! \~english Output operator to \a PICout +//! \~russian Оператор вывода в \a PICout template inline PICout operator <<(PICout s, const PIVector & v) { s.space(); @@ -1853,7 +1965,8 @@ inline PICout operator <<(PICout s, const PIVector & v) { return s; } -template inline void piSwap(PIVector & f, PIVector & s) {f.swap(s);} +template +inline void piSwap(PIVector & f, PIVector & s) {f.swap(s);} #endif // PIVECTOR_H