diff --git a/libs/main/containers/pideque.h b/libs/main/containers/pideque.h index 9220fdaf..0978a7bf 100644 --- a/libs/main/containers/pideque.h +++ b/libs/main/containers/pideque.h @@ -1,8 +1,17 @@ -/*! \file pideque.h - * \brief Dynamic array of any type - * - * This file declares PIDeque -*/ +//! \addtogroup Containers +//! \{ +//! \file pideque.h +//! \brief +//! \~english Declares \a PIDeque +//! \~russian Объявление \a PIDeque +//! \~\authors +//! \~english +//! Ivan Pelipenko peri4ko@yandex.ru; +//! Andrey Bychkov work.a.b@yandex.ru; +//! \~russian +//! Иван Пелипенко peri4ko@yandex.ru; +//! Андрей Бычков work.a.b@yandex.ru; +//! \~\} /* PIP - Platform Independent Primitives Dynamic array of any type @@ -28,6 +37,69 @@ #include "picontainers.h" +//! \addtogroup Containers +//! \{ +//! \class PIDeque +//! \brief +//! \~english Sequence two-way linear container - dynamic size array of any type. +//! \~russian Последовательный двухсторонний контейнер с линейной памятью - динамический массив любого типа. +//! \~\} +//! \details +//! \~english +//! The elements are stored contiguously, +//! which means that elements can be accessed not only through iterators, +//! but also using offsets to regular pointers to elements. +//! This means that a pointer to an element of a PIDeque may be passed to any function +//! that expects a pointer to an element of an array. +//! To add elements you can use functions \a append() and \a insert(), +//! to remove elements you can use functions \a remove() and \a clear(). +//! Change size by function \a resize(). +//! +//! The storage of the PIDeque is handled automatically, +//! being expanded as needed. +//! PIDeque usually occupy more space than \a PIVector, +//! because more memory is allocated to handle future growth +//! from both the beginning and the end. +//! This way a PIDeque does not need to reallocate each time an element is inserted, +//! but only when the additional memory is exhausted. +//! The total amount of allocated memory can be queried using \a capacity() function. +//! Reallocations are usually costly operations in terms of performance. +//! The \a reserve() function can be used to eliminate reallocations +//! if the number of elements is known beforehand. +//! +//! The complexity (efficiency) of common operations on PIDeque is as follows: +//! - Random access - constant 𝓞(1) +//! - Insertion or removal of elements at the end or begin - amortized constant 𝓞(1) +//! - Insertion or removal of elements - linear in the distance to the end of the array 𝓞(n) +//! +//! \~russian +//! Элементы хранятся непрерывно, а значит доступны не только через итераторы, +//! но и с помощью смещений для обычных указателей на элементы. +//! Это означает, что указатель на элемент PIDeque может передаваться в любую функцию, +//! ожидающую указатель на элемент массива. +//! Добавить элементы можно с помощью функции \a append() или \a insert(), +//! а удалить с помощью \a remove() или \a clear(). +//! Изменить размер можно функцией \a resize(). +//! +//! Память PIDeque обрабатывается автоматически, +//! расширяясь по мере необходимости. +//! PIDeque занимает больше места, чем \a PIVector, поскольку +//! больше памяти выделяется для обработки будущего роста и с начала и с конца. +//! Таким образом, память для PIDeque требуется выделять +//! не при каждой вставке элемента, а только после исчерпания дополнительной памяти. +//! Общий объём выделенной памяти можно получить с помощью функции \a capacity(). +//! +//! Выделение памяти обычно является дорогостоящей операцией +//! с точки зрения производительности. +//! Функцию \a reserve() можно использовать для исключения выделения памяти, +//! если количество элементов известно заранее. +//! +//! Сложность (эффективность) обычных операций над PIDeque следующая: +//! - Произвольный доступ — постоянная 𝓞(1) +//! - Вставка и удаление элементов в конце или начале — амортизированная постоянная 𝓞(1) +//! - Вставка и удаление элементов — линейная по расстоянию до конца массива 𝓞(n) +//! +//! \~\sa \a PIVector, \a PIMap template class PIDeque { public: diff --git a/libs/main/containers/pivector.h b/libs/main/containers/pivector.h index 710d11b2..a343ce74 100644 --- a/libs/main/containers/pivector.h +++ b/libs/main/containers/pivector.h @@ -69,7 +69,7 @@ //! The complexity (efficiency) of common operations on vectors is as follows: //! - Random access - constant 𝓞(1) //! - Insertion or removal of elements at the end - amortized constant 𝓞(1) -//! - Insertion or removal of elements - linear in the distance to the end of the vector 𝓞(n) +//! - Insertion or removal of elements - linear in the distance to the end of the array 𝓞(n) //! //! \~russian //! Элементы хранятся непрерывно, а значит доступны не только через итераторы, @@ -97,7 +97,7 @@ //! Сложность (эффективность) обычных операций над векторами следующая: //! - Произвольный доступ — постоянная 𝓞(1) //! - Вставка и удаление элементов в конце — амортизированная постоянная 𝓞(1) -//! - Вставка и удаление элементов — линейная по расстоянию до конца вектора 𝓞(n) +//! - Вставка и удаление элементов — линейная по расстоянию до конца массива 𝓞(n) //! //! \~\sa \a PIDeueue, \a PIMap template