merged AI doc, some new pages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \file picontainers.h
|
||||
//! \~\file picontainers.h
|
||||
//! \brief
|
||||
//! \~english Base macros for generic containers
|
||||
//! \~russian Базовые макросы для контейнеров
|
||||
@@ -74,17 +74,14 @@ public:
|
||||
template<typename T>
|
||||
class _PIContainerConstants {
|
||||
public:
|
||||
// minimum elements for container
|
||||
static size_t minCountPoT() {
|
||||
static const size_t ret = _PIContainerConstantsBase::calcMinCountPoT(sizeof(T));
|
||||
return ret;
|
||||
}
|
||||
// maximum elements for 2^n growth
|
||||
static size_t maxCountForPoT() {
|
||||
static const size_t ret = _PIContainerConstantsBase::calcMaxCountForPoT(sizeof(T));
|
||||
return ret;
|
||||
}
|
||||
// add elements after 2^n growth
|
||||
static size_t stepAfterPoT() {
|
||||
static const size_t ret = _PIContainerConstantsBase::calcStepAfterPoT(sizeof(T));
|
||||
return ret;
|
||||
@@ -112,9 +109,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Template reverse wrapper over any container
|
||||
//! \~russian Шаблонная функция обертки любого контейнера для обратного доступа через итераторы
|
||||
template<typename C>
|
||||
_PIReverseWrapper<C> PIReverseWrap(C & c) {
|
||||
return _PIReverseWrapper<C>(c);
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
*/
|
||||
//! \defgroup Containers Containers
|
||||
//! \~\brief
|
||||
//! \~english Various standart containers realization
|
||||
//! \~russian Различные классы контейнеров
|
||||
//! \~english Container classes and related helpers
|
||||
//! \~russian Классы контейнеров и связанные вспомогательные сущности
|
||||
//!
|
||||
//! \~\details
|
||||
//! \~english \section cmake_module_Containers Building with CMake
|
||||
@@ -58,9 +58,8 @@
|
||||
//! \a PIVector2D | Линейный двумерный прямоугольный массив
|
||||
//!
|
||||
//!
|
||||
//! \~english \section stl_iterators STL-Style Iterators
|
||||
//! \~russian \section stl_iterators Итераторы в стиле STL
|
||||
//! \~english
|
||||
//! \section stl_iterators STL-Style Iterators
|
||||
//! \brief They are compatible with Qt's and STL's generic algorithms and are optimized for speed.
|
||||
//! \details
|
||||
//! For each container class, there are two STL-style iterator types:
|
||||
@@ -114,6 +113,7 @@
|
||||
//! can be used on the left side of the assignment operator.
|
||||
//!
|
||||
//! \~russian
|
||||
//! \section stl_iterators Итераторы в стиле STL
|
||||
//! \brief Они совместимы с базовыми алгоритмами Qt и STL и оптимизированы по скорости.
|
||||
//! \details
|
||||
//! Для каждого контейнерного класса есть два типа итераторов в стиле STL:
|
||||
@@ -167,6 +167,14 @@
|
||||
//! Для неконстантных итераторов, возвращаемое значение унарного оператора `*`
|
||||
//! может быть использовано с левой стороны от оператора присваивания.
|
||||
//!
|
||||
//! \~\file picontainersmodule.h
|
||||
//! \~\ingroup Containers
|
||||
//! \~\brief
|
||||
//! \~english Umbrella header for the Containers module.
|
||||
//! \~russian Общий заголовок модуля Containers.
|
||||
//! \~\details
|
||||
//! \~english Includes the primary public container headers.
|
||||
//! \~russian Подключает основные публичные заголовки контейнеров.
|
||||
//!
|
||||
//! \authors
|
||||
//! \~english
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \file pideque.h
|
||||
//! \~\file pideque.h
|
||||
//! \brief
|
||||
//! \~english Declares \a PIDeque
|
||||
//! \~russian Объявление \a PIDeque
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \file pimap.h
|
||||
//! \brief
|
||||
//! \~\file pimap.h
|
||||
//! \~\brief
|
||||
//! \~english Declares \a PIMap
|
||||
//! \~russian Объявление \a PIMap
|
||||
//! \~\authors
|
||||
@@ -52,32 +52,23 @@ class PIMapIteratorReverse;
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \class PIMap
|
||||
//! \brief
|
||||
//! \~english Associative array.
|
||||
//! \~russian Словарь.
|
||||
//! \~\brief
|
||||
//! \~english Map of unique keys and associated values.
|
||||
//! \~russian Словарь с уникальными ключами и связанными значениями.
|
||||
//! \~\}
|
||||
//! \details
|
||||
//! \~\details
|
||||
//! \~english
|
||||
//! A collection of key/value pairs, from which you retrieve a value using its associated key.
|
||||
//! There is a finite number of keys in the map, and each key has exactly one value associated with it.
|
||||
//! \a value() returns value for key and leave map
|
||||
//! unchaged in any case. \a operator [] create entry in map if
|
||||
//! there is no entry for given key. You can retrieve all
|
||||
//! keys by method \a keys() and all values by methos \a values().
|
||||
//! To iterate all entries use class PIMapIterator, or methods
|
||||
//! \a makeIterator() and \a makeReverseIterator().
|
||||
//! A key in the Map may only occur once.
|
||||
//! Stores key/value pairs and keeps keys unique.
|
||||
//! \a value() returns the value for a key or the provided default,
|
||||
//! while \a operator[] creates a default value for a missing key.
|
||||
//! Use \a keys() and \a values() to retrieve map contents,
|
||||
//! and \a makeIterator() or \a makeReverseIterator() to traverse entries.
|
||||
//! \~russian
|
||||
//! Словари, в принципе, похожи на обычные, используемые в повседневной жизни.
|
||||
//! Они хранят элементы одного и того же типа, индексируемые ключевыми значениями.
|
||||
//! Достоинство словаря в том, что он позволяет быстро получать значение,
|
||||
//! ассоциированное с заданным ключом.
|
||||
//! Ключи должны быть уникальными.
|
||||
//! Элемент
|
||||
//! В контейнеры этого типа заносятся элементы вместе с ключами,
|
||||
//! по которым их можно найти, которыми могут выступать значения любого типа.
|
||||
//! \a operator [] позволяет получить доступ к элементу по ключу,
|
||||
//! и если такого эелемента не было, то он будет создан.
|
||||
//! Хранит пары ключ/значение и поддерживает уникальность ключей.
|
||||
//! \a value() возвращает значение по ключу или значение по умолчанию,
|
||||
//! а \a operator[] создает значение по умолчанию для отсутствующего ключа.
|
||||
//! Для получения содержимого используйте \a keys() и \a values(),
|
||||
//! а для обхода элементов - \a makeIterator() или \a makeReverseIterator().
|
||||
template<typename Key, typename T>
|
||||
class PIMap {
|
||||
template<typename Key1, typename T1>
|
||||
@@ -240,12 +231,11 @@ public:
|
||||
inline const_iterator begin() const { return const_iterator(this, 0); }
|
||||
inline const_iterator end() const { return const_iterator(this, size()); }
|
||||
|
||||
//! \~english Returns a reverse iterator to the first element of the reversed array.
|
||||
//! \~english Returns a reverse iterator to the last map entry.
|
||||
//! \~russian Обратный итератор на первый элемент.
|
||||
inline reverse_iterator rbegin() { return reverse_iterator(this, size() - 1); }
|
||||
|
||||
//! \~english Returns a reverse iterator to the element.
|
||||
//! following the last element of the reversed array.
|
||||
//! \~english Returns a reverse iterator to the position before the first map entry.
|
||||
//! \~russian Обратный итератор на элемент,
|
||||
//! следующий за последним элементом.
|
||||
inline reverse_iterator rend() { return reverse_iterator(this, -1); }
|
||||
@@ -265,13 +255,13 @@ public:
|
||||
//! \relatesalso PIMapIteratorReverse
|
||||
inline PIMapIteratorReverse<Key, T> makeReverseIterator() { return PIMapIteratorReverse<Key, T>(*this); }
|
||||
|
||||
//! \~english Number of elements in the container.
|
||||
//! \~russian Количество элементов массива.
|
||||
//! \~english Number of entries in the map.
|
||||
//! \~russian Количество элементов в словаре.
|
||||
//! \~\sa \a size_s(), \a capacity(), \a isEmpty(), \a isNotEmpty(), \a resize(), \a reserve()
|
||||
inline size_t size() const { return pim_content.size(); }
|
||||
|
||||
//! \~english Number of elements in the container as signed value.
|
||||
//! \~russian Количество элементов массива в виде знакового числа.
|
||||
//! \~english Number of entries in the map as a signed value.
|
||||
//! \~russian Количество элементов в словаре в виде знакового числа.
|
||||
//! \~\sa \a size(), \a capacity(), \a isEmpty(), \a isNotEmpty(), \a resize(), \a reserve()
|
||||
inline int size_s() const { return pim_content.size_s(); }
|
||||
|
||||
@@ -280,19 +270,13 @@ public:
|
||||
//! \~\sa \a size(), \a size_s(), \a capacity(), \a isEmpty(), \a isNotEmpty(), \a resize(), \a reserve()
|
||||
inline size_t length() const { return pim_content.size(); }
|
||||
|
||||
//! \~english Checks if the container has no elements.
|
||||
//! \~russian Проверяет пуст ли массив.
|
||||
//! \~\return
|
||||
//! \~english **true** if the container is empty, **false** otherwise
|
||||
//! \~russian **true** если массив пуст, **false** иначе.
|
||||
//! \~english Checks whether the map is empty.
|
||||
//! \~russian Проверяет, пуст ли словарь.
|
||||
//! \~\sa \a size(), \a size_s(), \a isEmpty(), \a isNotEmpty(), \a resize(), \a reserve()
|
||||
inline bool isEmpty() const { return (pim_content.size() == 0); }
|
||||
|
||||
//! \~english Checks if the container has elements.
|
||||
//! \~russian Проверяет не пуст ли массив.
|
||||
//! \~\return
|
||||
//! \~english **true** if the container is not empty, **false** otherwise
|
||||
//! \~russian **true** если массив не пуст, **false** иначе.
|
||||
//! \~english Checks whether the map contains entries.
|
||||
//! \~russian Проверяет, содержит ли словарь элементы.
|
||||
//! \~\sa \a size(), \a size_s(), \a isEmpty(), \a isNotEmpty(), \a resize(), \a reserve()
|
||||
inline bool isNotEmpty() const { return (pim_content.size() > 0); }
|
||||
|
||||
@@ -304,7 +288,7 @@ public:
|
||||
//! the function inserts a default-constructed value into the map with key `key`,
|
||||
//! and returns a reference to it.
|
||||
//! \~russian Если элемента с таким ключом `key` не существует,
|
||||
//! то он будет создан конструктором по умолчанию и добавлен в массив
|
||||
//! то он будет создан конструктором по умолчанию и добавлен в словарь
|
||||
//! по ключу `key`, а затем возвращена ссылка на этот новый элемент.
|
||||
//! \~\code
|
||||
//! PIMap <PIString, int> m;
|
||||
@@ -339,8 +323,8 @@ public:
|
||||
return _value(i);
|
||||
}
|
||||
|
||||
//! \~english Remove element with key `key` from the array and return it.
|
||||
//! \~russian Удаляет элемент с ключом `key` из массива и возвращает его.
|
||||
//! \~english Removes entry with key `key` and returns its value.
|
||||
//! \~russian Удаляет элемент с ключом `key` и возвращает его значение.
|
||||
inline T take(const Key & key, const T & default_ = T()) {
|
||||
bool f(false);
|
||||
const ssize_t i = _find(key, f);
|
||||
@@ -350,8 +334,8 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Inserts all elements in array `other` to this array with overwrite.
|
||||
//! \~russian Вставляет все элементы `other` этот массив с перезаписью.
|
||||
//! \~english Inserts all entries from `other`, overwriting existing keys.
|
||||
//! \~russian Добавляет все элементы из `other`, перезаписывая существующие ключи.
|
||||
inline PIMap<Key, T> & operator<<(const PIMap<Key, T> & other) {
|
||||
#ifndef NDEBUG
|
||||
if (&other == this) {
|
||||
@@ -375,24 +359,24 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Compare operator with array `m`.
|
||||
//! \~russian Оператор сравнения с массивом `m`.
|
||||
//! \~english Compares this map with `m`.
|
||||
//! \~russian Сравнивает этот словарь с `m`.
|
||||
inline bool operator==(const PIMap<Key, T> & m) const { return (pim_content == m.pim_content && pim_index == m.pim_index); }
|
||||
|
||||
//! \~english Compare operator with array `m`.
|
||||
//! \~russian Оператор сравнения с массивом `m`.
|
||||
//! \~english Compares this map with `m`.
|
||||
//! \~russian Сравнивает этот словарь с `m`.
|
||||
inline bool operator!=(const PIMap<Key, T> & m) const { return (pim_content != m.pim_content || pim_index != m.pim_index); }
|
||||
|
||||
//! \~english Tests if element with key `key` exists in the array.
|
||||
//! \~russian Проверяет наличие элемента с ключом `key` в массиве.
|
||||
//! \~english Checks whether the map contains key `key`.
|
||||
//! \~russian Проверяет, содержит ли словарь ключ `key`.
|
||||
inline bool contains(const Key & key) const {
|
||||
bool f(false);
|
||||
_find(key, f);
|
||||
return f;
|
||||
}
|
||||
|
||||
//! \~english Tests if element with value `value` exists in the array.
|
||||
//! \~russian Проверяет наличие элемента со значением `value` в массиве.
|
||||
//! \~english Checks whether the map contains value `value`.
|
||||
//! \~russian Проверяет, содержит ли словарь значение `value`.
|
||||
inline bool containsValue(const T & value) const { return pim_content.contains(value); }
|
||||
|
||||
//! \~english Attempts to allocate memory for at least `new_size` elements.
|
||||
@@ -403,8 +387,8 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Remove element with key `key` from the array.
|
||||
//! \~russian Удаляет элемент с ключом `key` из массива.
|
||||
//! \~english Removes entry with key `key`.
|
||||
//! \~russian Удаляет элемент с ключом `key`.
|
||||
inline PIMap<Key, T> & remove(const Key & key) {
|
||||
bool f(false);
|
||||
const ssize_t i = _find(key, f);
|
||||
@@ -413,7 +397,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//! \~english Remove all elements in the array
|
||||
//! \~english Removes all entries
|
||||
//! passes the test implemented by the provided function `test`.
|
||||
//! \~russian Удаляет все элементы, удовлетворяющие условию,
|
||||
//! заданному в передаваемой функции `test`.
|
||||
@@ -433,8 +417,8 @@ public:
|
||||
inline PIMap<Key, T> & erase(const Key & key) { return remove(key); }
|
||||
|
||||
|
||||
//! \~english Clear array, remove all elements.
|
||||
//! \~russian Очищает массив, удаляет все элементы.
|
||||
//! \~english Clears the map.
|
||||
//! \~russian Очищает словарь.
|
||||
//! \~\details
|
||||
//! \~\note
|
||||
//! \~english Reserved memory will not be released.
|
||||
@@ -446,8 +430,8 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Swaps array `v` other with this array.
|
||||
//! \~russian Меняет местами массив `v` с этим массивом.
|
||||
//! \~english Swaps this map with `other`.
|
||||
//! \~russian Меняет местами этот словарь и `other`.
|
||||
//! \~\details
|
||||
//! \~english This operation is very fast and never fails.
|
||||
//! \~russian Эта операция выполняется мгновенно без копирования памяти и никогда не дает сбоев.
|
||||
@@ -456,8 +440,8 @@ public:
|
||||
pim_index.swap(other.pim_index);
|
||||
}
|
||||
|
||||
//! \~english Inserts value `value` with key `key` in the array.
|
||||
//! \~russian Вставляет значение `value` с ключом `key` в массив.
|
||||
//! \~english Inserts value `value` for key `key`.
|
||||
//! \~russian Вставляет значение `value` по ключу `key`.
|
||||
//! \~\details
|
||||
//! \~english If an element with the key `key` already exists, it will be overwritten with the value `value`.
|
||||
//! \~russian Если элемент с ключом `key` уже существует, то он будет перезаписан на значение `value`.
|
||||
@@ -485,8 +469,8 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Inserts value `pair` in the array.
|
||||
//! \~russian Вставляет пару `pair` в массив.
|
||||
//! \~english Inserts entry `pair`.
|
||||
//! \~russian Вставляет элемент `pair`.
|
||||
//! \~\details
|
||||
//! \~english The first element of the pair is the key, and the second is the value.
|
||||
//! \~russian Первый элемент пары является ключом, а второй значением.
|
||||
@@ -526,8 +510,8 @@ public:
|
||||
return _value(i);
|
||||
}
|
||||
|
||||
//! \~english Returns an array of values of all elements
|
||||
//! \~russian Возвращает массив значений всех эелметнов
|
||||
//! \~english Returns values of all map entries.
|
||||
//! \~russian Возвращает значения всех элементов словаря.
|
||||
inline PIVector<T> values() const { return pim_content; }
|
||||
|
||||
//! \~english Returns the key of the first element
|
||||
@@ -544,8 +528,8 @@ public:
|
||||
return default_;
|
||||
}
|
||||
|
||||
//! \~english Returns an array of keys of all elements
|
||||
//! \~russian Возвращает массив ключей всех элементов
|
||||
//! \~english Returns keys of all map entries.
|
||||
//! \~russian Возвращает ключи всех элементов словаря.
|
||||
inline PIVector<Key> keys() const {
|
||||
PIVector<Key> ret;
|
||||
ret.reserve(pim_index.size());
|
||||
@@ -555,8 +539,8 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Execute function `void f(const Key & key, const T & value)` for every element in array.
|
||||
//! \~russian Выполняет функцию `void f(const Key & key, const T & value)` для каждого элемента массива.
|
||||
//! \~english Calls `f` for every map entry.
|
||||
//! \~russian Вызывает `f` для каждого элемента словаря.
|
||||
inline void forEach(std::function<void(const Key & key, const T & value)> f) const {
|
||||
for (int i = 0; i < pim_index.size_s(); ++i) {
|
||||
const auto & mi(pim_index[i]);
|
||||
@@ -564,10 +548,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//! \~english Сreates a new map PIMap<Key2, T2> populated with the results
|
||||
//! of calling a provided function `PIPair<Key2, T2> f(const Key & key, const T & value)` on every element in the calling array.
|
||||
//! \~russian Создаёт новый словарь PIMap<Key2, T2> с результатом вызова указанной функции
|
||||
//! `PIPair<Key2, T2> f(const Key & key, const T & value)` для каждого элемента массива.
|
||||
//! \~english Creates a new \a PIMap from results of applying `f` to each map entry.
|
||||
//! \~russian Создает новый \a PIMap из результатов применения `f` к каждому элементу словаря.
|
||||
template<typename Key2, typename T2>
|
||||
inline PIMap<Key2, T2> map(std::function<PIPair<Key2, T2>(const Key & key, const T & value)> f) const {
|
||||
PIMap<Key2, T2> ret;
|
||||
@@ -579,10 +561,8 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Сreates a new array PIVector<ST> populated with the results
|
||||
//! of calling a provided function `ST f(const Key & key, const T & value)` on every element in the calling array.
|
||||
//! \~russian Создаёт новый массив PIVector<ST> с результатом вызова указанной функции
|
||||
//! `ST f(const Key & key, const T & value)` для каждого элемента массива.
|
||||
//! \~english Creates a new \a PIVector from results of applying `f` to each map entry.
|
||||
//! \~russian Создает новый \a PIVector из результатов применения `f` к каждому элементу словаря.
|
||||
template<typename ST>
|
||||
inline PIVector<ST> map(std::function<ST(const Key & key, const T & value)> f) const {
|
||||
PIVector<ST> ret;
|
||||
@@ -594,9 +574,9 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Returns a new array with all elements
|
||||
//! \~english Returns a new map with all entries
|
||||
//! that pass the test implemented by the provided function `bool test(const Key & key, const T & value)`.
|
||||
//! \~russian Возвращает новый массив со всеми элементами,
|
||||
//! \~russian Возвращает новый словарь со всеми элементами,
|
||||
//! прошедшими проверку, задаваемую в передаваемой функции `bool test(const Key & key, const T & value)`.
|
||||
inline PIMap<Key, T> filter(std::function<bool(const Key & key, const T & value)> test) const {
|
||||
PIMap<Key, T> ret;
|
||||
@@ -688,17 +668,17 @@ private:
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \class PIMapIteratorConst
|
||||
//! \brief
|
||||
//! \~\brief
|
||||
//! \~english Java-style iterator for \a PIMap.
|
||||
//! \~russian Итератор Java стиля для \a PIMap.
|
||||
//! \~\}
|
||||
//! \details
|
||||
//! \~english
|
||||
//! This class used to easy serial access keys and values in PIMap with read only permitions.
|
||||
//! Use constructor to create iterator, or use \a PIMap::makeIterator()
|
||||
//! Provides sequential read-only access to keys and values in \a PIMap.
|
||||
//! Use the constructor directly or call \a PIMap::makeIterator().
|
||||
//! \~russian
|
||||
//! Этот класс используется для удобного перебора ключей и значений всего словаря только для чтения.
|
||||
//! Можно использовать конструктор, в который передаётся словарь, или функцию словаря \a PIMap::makeIterator().
|
||||
//! Используется для последовательного перебора ключей и значений \a PIMap только для чтения.
|
||||
//! Можно использовать конструктор или вызвать \a PIMap::makeIterator().
|
||||
//! \~
|
||||
//! \code
|
||||
//! PIMap<int, PIString> m;
|
||||
@@ -758,17 +738,17 @@ private:
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \class PIMapIteratorConstReverse
|
||||
//! \brief
|
||||
//! \~\brief
|
||||
//! \~english Java-style reverse iterator for \a PIMap.
|
||||
//! \~russian Итератор Java стиля для \a PIMap в обратном порядке.
|
||||
//! \~\}
|
||||
//! \details
|
||||
//! \~english
|
||||
//! This class used to easy serial reverse access keys and values in PIMap with read only permitions.
|
||||
//! Use constructor to create iterator, or use \a PIMap::makeReverseIterator().
|
||||
//! Provides sequential reverse read-only access to keys and values in \a PIMap.
|
||||
//! Use the constructor directly or call \a PIMap::makeReverseIterator().
|
||||
//! \~russian
|
||||
//! Этот класс используется для удобного перебора ключей и значений всего словаря в обратном порядке только для чтения.
|
||||
//! Можно использовать конструктор, в который передаётся словарь, или функцию словаря \a PIMap::makeReverseIterator().
|
||||
//! Используется для последовательного обратного перебора ключей и значений \a PIMap только для чтения.
|
||||
//! Можно использовать конструктор или вызвать \a PIMap::makeReverseIterator().
|
||||
//! \~
|
||||
//! \code
|
||||
//! PIMap<int, PIString> m;
|
||||
@@ -827,17 +807,17 @@ private:
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \class PIMapIterator
|
||||
//! \brief
|
||||
//! \~\brief
|
||||
//! \~english Java-style iterator for \a PIMap.
|
||||
//! \~russian Итератор Java стиля для \a PIMap.
|
||||
//! \~\}
|
||||
//! \details
|
||||
//! \~english
|
||||
//! This class used to easy serial access keys and values in PIMap with write permitions.
|
||||
//! Use constructor to create iterator, or use \a PIMap::makeIterator()
|
||||
//! Provides sequential access to keys and values in \a PIMap with write access to values.
|
||||
//! Use the constructor directly or call \a PIMap::makeIterator().
|
||||
//! \~russian
|
||||
//! Этот класс используется для удобного перебора ключей и значений всего словаря с доступом на запись.
|
||||
//! Можно использовать конструктор, в который передаётся словарь, или функцию словаря \a PIMap::makeIterator().
|
||||
//! Используется для последовательного перебора ключей и значений \a PIMap с доступом на запись.
|
||||
//! Можно использовать конструктор или вызвать \a PIMap::makeIterator().
|
||||
//! \~
|
||||
//! \code
|
||||
//! PIMap<int, PIString> m;
|
||||
@@ -897,17 +877,17 @@ private:
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \class PIMapIteratorReverse
|
||||
//! \brief
|
||||
//! \~\brief
|
||||
//! \~english Java-style reverse iterator for \a PIMap.
|
||||
//! \~russian Итератор Java стиля для \a PIMap в обратном порядке.
|
||||
//! \~\}
|
||||
//! \details
|
||||
//! \~english
|
||||
//! This class used to easy serial reverse access keys and values in PIMap with write permitions.
|
||||
//! Use constructor to create iterator, or use \a PIMap::makeReverseIterator().
|
||||
//! Provides sequential reverse access to keys and values in \a PIMap with write access to values.
|
||||
//! Use the constructor directly or call \a PIMap::makeReverseIterator().
|
||||
//! \~russian
|
||||
//! Этот класс используется для удобного перебора ключей и значений всего словаря в обратном порядке с доступом на запись.
|
||||
//! Можно использовать конструктор, в который передаётся словарь, или функцию словаря \a PIMap::makeReverseIterator().
|
||||
//! Используется для последовательного обратного перебора ключей и значений \a PIMap с доступом на запись.
|
||||
//! Можно использовать конструктор или вызвать \a PIMap::makeReverseIterator().
|
||||
//! \~
|
||||
//! \code
|
||||
//! PIMap<int, PIString> m;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \file pipair.h
|
||||
//! \~\file pipair.h
|
||||
//! \brief
|
||||
//! \~english Declares \a PIPair
|
||||
//! \~russian Объявление \a PIPair
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \file piqueue.h
|
||||
//! \~\file piqueue.h
|
||||
//! \brief
|
||||
//! \~english Declares \a PIQueue
|
||||
//! \~russian Объявление \a PIQueue
|
||||
@@ -40,78 +40,76 @@
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \class PIQueue
|
||||
//! \brief
|
||||
//! \~english A container class inherited from the \a PIDeque with queue functionality.
|
||||
//! \~russian Класс контейнера наследованый от \a PIDeque с функциональностью очереди.
|
||||
//! \~\brief
|
||||
//! \~english Queue container built on top of \a PIDeque.
|
||||
//! \~russian Контейнер очереди, построенный поверх \a PIDeque.
|
||||
//! \~\}
|
||||
//! \details
|
||||
//! \~english The container is a array of elements organized according to the FIFO principle (first in, first out).
|
||||
//! Adds \a enqueue() and \dequeue() functions to \a PIDeque.
|
||||
//! \~russian Контейнер представляющий массив элементов, организованных по принципу FIFO (первым пришёл — первым вышел).
|
||||
//! Добавляет к \a PIDeque функции \a enqueue() и \a dequeue().
|
||||
//! \~english Stores elements in FIFO order and adds \a enqueue() and \a dequeue() to \a PIDeque.
|
||||
//! \~russian Хранит элементы в порядке FIFO и добавляет к \a PIDeque функции \a enqueue() и \a dequeue().
|
||||
//! \~\sa \a PIDeque
|
||||
template<typename T>
|
||||
class PIQueue: public PIDeque<T> {
|
||||
public:
|
||||
//! \~english Constructs an empty array.
|
||||
//! \~russian Создает пустой массив.
|
||||
//! \~english Constructs an empty queue.
|
||||
//! \~russian Создает пустую очередь.
|
||||
PIQueue() {}
|
||||
|
||||
//! \~english Puts an element on the queue.
|
||||
//! \~russian Кладёт элемент в очередь.
|
||||
//! \~english Enqueues `v`.
|
||||
//! \~russian Добавляет `v` в очередь.
|
||||
PIDeque<T> & enqueue(const T & v) {
|
||||
PIDeque<T>::push_front(v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Move an element on the queue.
|
||||
//! \~russian Перемещает элемент в очередь.
|
||||
//! \~english Moves `v` into the queue.
|
||||
//! \~russian Перемещает `v` в очередь.
|
||||
PIDeque<T> & enqueue(T && v) {
|
||||
PIDeque<T>::push_front(std::move(v));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Retrieves and returns an element from the queue.
|
||||
//! \~russian Забирает и возвращает элемент из очереди.
|
||||
//! \~english Dequeues and returns the head element.
|
||||
//! \~russian Извлекает и возвращает головной элемент очереди.
|
||||
//! \~\details
|
||||
//! \note
|
||||
//! \~english This function assumes that the array isn't empty.
|
||||
//! Otherwise will be undefined behavior.
|
||||
//! \~russian Эта функция предполагает, что массив не пустой.
|
||||
//! \~english This function assumes that the queue is not empty.
|
||||
//! Otherwise behavior is undefined.
|
||||
//! \~russian Эта функция предполагает, что очередь не пуста.
|
||||
//! Иначе это приведёт к неопределённому поведению программы и ошибкам памяти.
|
||||
T dequeue() { return PIDeque<T>::take_back(); }
|
||||
|
||||
//! \~english Head element of the queue.
|
||||
//! \~russian Головной (верхний) элемент очереди.
|
||||
//! \~english Returns the head element.
|
||||
//! \~russian Возвращает головной элемент очереди.
|
||||
//! \~\details
|
||||
//! \note
|
||||
//! \~english Returns a reference to the head element of the queue.
|
||||
//! This function assumes that the array isn't empty.
|
||||
//! Otherwise will be undefined behavior.
|
||||
//! \~russian Возвращает ссылку на головной (верхний) элемент очереди.
|
||||
//! Эта функция предполагает, что массив не пустой.
|
||||
//! \~english Returns a reference to the head element.
|
||||
//! This function assumes that the queue is not empty.
|
||||
//! Otherwise behavior is undefined.
|
||||
//! \~russian Возвращает ссылку на головной элемент очереди.
|
||||
//! Эта функция предполагает, что очередь не пуста.
|
||||
//! Иначе это приведёт к неопределённому поведению программы и ошибкам памяти.
|
||||
T & head() { return PIDeque<T>::back(); }
|
||||
const T & head() const { return PIDeque<T>::back(); }
|
||||
|
||||
//! \~english Tail element of the queue.
|
||||
//! \~russian Хвостовой (нижний) элемент очереди.
|
||||
//! \~english Returns the tail element.
|
||||
//! \~russian Возвращает хвостовой элемент очереди.
|
||||
//! \~\details
|
||||
//! \~english Returns a reference to the tail element of the queue.
|
||||
//! This function assumes that the array isn't empty.
|
||||
//! Otherwise will be undefined behavior.
|
||||
//! \~russian Возвращает ссылку на хвостовой (нижний) элемент очереди.
|
||||
//! Эта функция предполагает, что массив не пустой.
|
||||
//! \~english Returns a reference to the tail element.
|
||||
//! This function assumes that the queue is not empty.
|
||||
//! Otherwise behavior is undefined.
|
||||
//! \~russian Возвращает ссылку на хвостовой элемент очереди.
|
||||
//! Эта функция предполагает, что очередь не пуста.
|
||||
//! Иначе это приведёт к неопределённому поведению программы и ошибкам памяти.
|
||||
T & tail() { return PIDeque<T>::front(); }
|
||||
const T & tail() const { return PIDeque<T>::front(); }
|
||||
|
||||
//! \~english Converts \a PIQueue to \a PIVector.
|
||||
//! \~russian Преобразует \a PIQueue в \a PIVector.
|
||||
//! \~english Returns queue contents as \a PIVector.
|
||||
//! \~russian Возвращает содержимое очереди в виде \a PIVector.
|
||||
PIVector<T> toVector() const { return PIVector<T>(PIDeque<T>::data(), PIDeque<T>::size()); }
|
||||
|
||||
//! \~english Converts \a PIQueue to \a PIDeque.
|
||||
//! \~russian Преобразует \a PIQueue в \a PIDeque.
|
||||
//! \~english Returns queue contents as \a PIDeque.
|
||||
//! \~russian Возвращает содержимое очереди в виде \a PIDeque.
|
||||
PIDeque<T> toDeque() const { return PIDeque<T>(*this); }
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/*! \file piset.h
|
||||
* \brief Set container
|
||||
*
|
||||
* This file declare PISet
|
||||
*/
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \~\file piset.h
|
||||
//! \~\brief
|
||||
//! \~english Declares \a PISet
|
||||
//! \~russian Объявление \a PISet
|
||||
//! \~\}
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Set container
|
||||
@@ -27,13 +29,33 @@
|
||||
|
||||
#include "pimap.h"
|
||||
|
||||
/*! \brief Set of any type
|
||||
* \details This class used to store collection of unique elements
|
||||
* of any type. You can only add values to set with \a operator<< or
|
||||
* with function \a insert(). You can discover if value already in
|
||||
* set with \a operator[] or with function \a find(). These function
|
||||
* has logarithmic complexity.
|
||||
*/
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \class PISet
|
||||
//! \~\brief
|
||||
//! \~english Set of unique values.
|
||||
//! \~russian Множество уникальных значений.
|
||||
//! \~\}
|
||||
//! \~\details
|
||||
//! \~english
|
||||
//! This class is used to store a collection of unique elements of any type.
|
||||
//! You can add values to the set using \a operator<< or the \a insert() function.
|
||||
//! You can check if a value already exists in the set using \a operator[] or the \a contains() function.
|
||||
//! These operations have logarithmic complexity.
|
||||
//! To iterate over all elements, use STL-style iterators \a begin() and \a end().
|
||||
//!
|
||||
//! The set is implemented as a wrapper around \a PIMap, where keys are the elements
|
||||
//! and values are dummy byte values (used only for storage).
|
||||
//! \~russian
|
||||
//! Этот класс используется для хранения коллекции уникальных элементов любого типа.
|
||||
//! Вы можете добавлять значения в множество с помощью \a operator<< или функции \a insert().
|
||||
//! Вы можете проверить, существует ли значение в множестве, используя \a operator[] или функцию \a contains().
|
||||
//! Эти операции имеют логарифмическую сложность.
|
||||
//! Для перебора всех элементов используйте итераторы в стиле STL \a begin() и \a end().
|
||||
//!
|
||||
//! Множество реализовано как обёртка над \a PIMap, где ключами являются элементы,
|
||||
//! а значениями являются фиктивные байтовые значения (используются только для хранения).
|
||||
//! \~\sa \a PIMap, \a PIVector
|
||||
template<typename T>
|
||||
class PISet: public PIMap<T, uchar> {
|
||||
typedef PIMap<T, uchar> _CSet;
|
||||
@@ -43,26 +65,31 @@ class PISet: public PIMap<T, uchar> {
|
||||
friend PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PISet<T1> & v);
|
||||
|
||||
public:
|
||||
//! Contructs an empty set
|
||||
//! \~english Constructs an empty set.
|
||||
//! \~russian Создает пустое множество.
|
||||
PISet() {}
|
||||
|
||||
//! Contructs set with one element "value"
|
||||
//! \~english Constructs a set containing `value`.
|
||||
//! \~russian Создает множество, содержащее `value`.
|
||||
explicit PISet(const T & value) { _CSet::insert(value, 0); }
|
||||
|
||||
//! Contructs set with elements "v0" and "v1"
|
||||
//! \~english Constructs a set containing `v0` and `v1`.
|
||||
//! \~russian Создает множество, содержащее `v0` и `v1`.
|
||||
PISet(const T & v0, const T & v1) {
|
||||
_CSet::insert(v0, 0);
|
||||
_CSet::insert(v1, 0);
|
||||
}
|
||||
|
||||
//! Contructs set with elements "v0", "v1" and "v2"
|
||||
//! \~english Constructs a set containing `v0`, `v1` and `v2`.
|
||||
//! \~russian Создает множество, содержащее `v0`, `v1` и `v2`.
|
||||
PISet(const T & v0, const T & v1, const T & v2) {
|
||||
_CSet::insert(v0, 0);
|
||||
_CSet::insert(v1, 0);
|
||||
_CSet::insert(v2, 0);
|
||||
}
|
||||
|
||||
//! Contructs set with elements "v0", "v1", "v2" and "v3"
|
||||
//! \~english Constructs a set containing `v0`, `v1`, `v2` and `v3`.
|
||||
//! \~russian Создает множество, содержащее `v0`, `v1`, `v2` и `v3`.
|
||||
PISet(const T & v0, const T & v1, const T & v2, const T & v3) {
|
||||
_CSet::insert(v0, 0);
|
||||
_CSet::insert(v1, 0);
|
||||
@@ -71,6 +98,9 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Constant iterator over \a PISet elements.
|
||||
//! \~russian Константный итератор по элементам \a PISet.
|
||||
class const_iterator {
|
||||
friend class PISet<T>;
|
||||
|
||||
@@ -86,75 +116,140 @@ public:
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
|
||||
//! \~english Constructs an invalid iterator.
|
||||
//! \~russian Создает недействительный итератор.
|
||||
inline const_iterator(): parent(0), pos(0) {}
|
||||
|
||||
//! \~english Returns the current element.
|
||||
//! \~russian Возвращает текущий элемент.
|
||||
inline const T & operator*() const { return parent->pim_index[pos].key; }
|
||||
|
||||
//! \~english Provides access to the current element.
|
||||
//! \~russian Предоставляет доступ к текущему элементу.
|
||||
inline const T & operator->() const { return parent->pim_index[pos].key; }
|
||||
|
||||
//! \~english Moves iterator to the next element.
|
||||
//! \~russian Перемещает итератор к следующему элементу.
|
||||
inline const_iterator & operator++() {
|
||||
++pos;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Returns iterator before incrementing.
|
||||
//! \~russian Возвращает итератор до увеличения.
|
||||
inline const_iterator operator++(int) {
|
||||
const auto tmp = *this;
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//! \~english Moves iterator to the previous element.
|
||||
//! \~russian Перемещает итератор к предыдущему элементу.
|
||||
inline const_iterator & operator--() {
|
||||
--pos;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Returns iterator before decrementing.
|
||||
//! \~russian Возвращает итератор до уменьшения.
|
||||
inline const_iterator operator--(int) {
|
||||
const auto tmp = *this;
|
||||
--*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//! \~english Adds offset of iterator `it`.
|
||||
//! \~russian Добавляет смещение итератора `it`.
|
||||
inline const_iterator & operator+=(const const_iterator & it) {
|
||||
pos += it.pos;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Advances iterator by `p` elements.
|
||||
//! \~russian Сдвигает итератор вперед на `p` элементов.
|
||||
inline const_iterator & operator+=(size_t p) {
|
||||
pos += p;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Subtracts offset of iterator `it`.
|
||||
//! \~russian Вычитает смещение итератора `it`.
|
||||
inline const_iterator & operator-=(const const_iterator & it) {
|
||||
pos -= it.pos;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Moves iterator back by `p` elements.
|
||||
//! \~russian Сдвигает итератор назад на `p` элементов.
|
||||
inline const_iterator & operator-=(size_t p) {
|
||||
pos -= p;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Returns iterator shifted back by `p`.
|
||||
//! \~russian Возвращает итератор, сдвинутый назад на `p`.
|
||||
friend inline const_iterator operator-(size_t p, const const_iterator & it) { return it - p; }
|
||||
|
||||
//! \~english Returns iterator shifted back by `p`.
|
||||
//! \~russian Возвращает итератор, сдвинутый назад на `p`.
|
||||
friend inline const_iterator operator-(const const_iterator & it, size_t p) {
|
||||
auto tmp = it;
|
||||
tmp -= p;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//! \~english Returns distance between iterators.
|
||||
//! \~russian Возвращает расстояние между итераторами.
|
||||
friend inline std::ptrdiff_t operator-(const const_iterator & it1, const const_iterator & it2) { return it1.pos - it2.pos; }
|
||||
|
||||
//! \~english Returns iterator shifted forward by `p`.
|
||||
//! \~russian Возвращает итератор, сдвинутый вперед на `p`.
|
||||
friend inline const_iterator operator+(size_t p, const const_iterator & it) { return it + p; }
|
||||
|
||||
//! \~english Returns iterator shifted forward by `p`.
|
||||
//! \~russian Возвращает итератор, сдвинутый вперед на `p`.
|
||||
friend inline const_iterator operator+(const const_iterator & it, size_t p) {
|
||||
auto tmp = it;
|
||||
tmp += p;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//! \~english Checks iterator equality.
|
||||
//! \~russian Проверяет равенство итераторов.
|
||||
inline bool operator==(const const_iterator & it) const { return (pos == it.pos); }
|
||||
|
||||
//! \~english Checks iterator inequality.
|
||||
//! \~russian Проверяет неравенство итераторов.
|
||||
inline bool operator!=(const const_iterator & it) const { return (pos != it.pos); }
|
||||
|
||||
//! \~english Checks whether `it1` is before `it2`.
|
||||
//! \~russian Проверяет, находится ли `it1` перед `it2`.
|
||||
friend inline bool operator<(const const_iterator & it1, const const_iterator & it2) { return it1.pos < it2.pos; }
|
||||
|
||||
//! \~english Checks whether `it1` is before or equal to `it2`.
|
||||
//! \~russian Проверяет, находится ли `it1` перед `it2` или совпадает с ним.
|
||||
friend inline bool operator<=(const const_iterator & it1, const const_iterator & it2) { return it1.pos <= it2.pos; }
|
||||
|
||||
//! \~english Checks whether `it1` is after `it2`.
|
||||
//! \~russian Проверяет, находится ли `it1` после `it2`.
|
||||
friend inline bool operator>(const const_iterator & it1, const const_iterator & it2) { return it1.pos > it2.pos; }
|
||||
|
||||
//! \~english Checks whether `it1` is after or equal to `it2`.
|
||||
//! \~russian Проверяет, находится ли `it1` после `it2` или совпадает с ним.
|
||||
friend inline bool operator>=(const const_iterator & it1, const const_iterator & it2) { return it1.pos >= it2.pos; }
|
||||
};
|
||||
|
||||
|
||||
//! \~english Returns iterator to the first element.
|
||||
//! \~russian Возвращает итератор на первый элемент.
|
||||
inline const_iterator begin() const { return const_iterator(this, 0); }
|
||||
|
||||
//! \~english Returns iterator following the last element.
|
||||
//! \~russian Возвращает итератор на элемент, следующий за последним.
|
||||
inline const_iterator end() const { return const_iterator(this, _CSet::size()); }
|
||||
|
||||
//! Contructs set from vector of elements
|
||||
//! \~english Constructs a set from vector `values`.
|
||||
//! \~russian Создает множество из вектора `values`.
|
||||
explicit PISet(const PIVector<T> & values) {
|
||||
if (values.isEmpty()) return;
|
||||
for (int i = 0; i < values.size_s(); ++i) {
|
||||
@@ -162,7 +257,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//! Contructs set from deque of elements
|
||||
//! \~english Constructs a set from deque `values`.
|
||||
//! \~russian Создает множество из дека `values`.
|
||||
explicit PISet(const PIDeque<T> & values) {
|
||||
if (values.isEmpty()) return;
|
||||
for (int i = 0; i < values.size_s(); ++i) {
|
||||
@@ -172,65 +268,83 @@ public:
|
||||
|
||||
typedef T key_type;
|
||||
|
||||
//! \~english Inserts `t` into the set.
|
||||
//! \~russian Добавляет `t` в множество.
|
||||
PISet<T> & operator<<(const T & t) {
|
||||
_CSet::insert(t, 0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Moves `t` into the set.
|
||||
//! \~russian Перемещает `t` в множество.
|
||||
PISet<T> & operator<<(T && t) {
|
||||
_CSet::insert(std::move(t), 0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Inserts all elements from `other`.
|
||||
//! \~russian Добавляет все элементы из `other`.
|
||||
PISet<T> & operator<<(const PISet<T> & other) {
|
||||
(*(_CSet *)this) << *((_CSet *)&other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Tests if element `key` exists in the set.
|
||||
//! \~russian Проверяет наличие элемента `key` в массиве.
|
||||
//! \~english Tests whether element `t` exists in the set.
|
||||
//! \~russian Проверяет наличие элемента `t` в множестве.
|
||||
inline bool contains(const T & t) const { return _CSet::contains(t); }
|
||||
|
||||
//! Returns if element "t" exists in this set
|
||||
//! \~english Checks whether element `t` exists in the set.
|
||||
//! \~russian Проверяет наличие элемента `t` в множестве.
|
||||
bool operator[](const T & t) const { return _CSet::contains(t); }
|
||||
|
||||
//! Returns if element "t" exists in this set
|
||||
//! \~english Removes element `t` from the set.
|
||||
//! \~russian Удаляет элемент `t` из множества.
|
||||
PISet<T> & remove(const T & t) {
|
||||
_CSet::remove(t);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Unite set with "v"
|
||||
//! \~english Unites the set with `v`.
|
||||
//! \~russian Объединяет множество с `v`.
|
||||
PISet<T> & unite(const PISet<T> & v) {
|
||||
for (const auto & i: v)
|
||||
_CSet::insert(i, 0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Subtract set with "v"
|
||||
//! \~english Removes all elements present in `v`.
|
||||
//! \~russian Удаляет все элементы, присутствующие в `v`.
|
||||
PISet<T> & subtract(const PISet<T> & v) {
|
||||
for (const auto & i: v)
|
||||
_CSet::remove(i);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Intersect set with "v"
|
||||
//! \~english Leaves only elements also present in `v`.
|
||||
//! \~russian Оставляет только элементы, которые есть и в `v`.
|
||||
PISet<T> & intersect(const PISet<T> & v) {
|
||||
_CSet::removeWhere([&v](const T & k, uchar) { return !v.contains(k); });
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Unite set with "v"
|
||||
//! \~english Same as \a unite().
|
||||
//! \~russian Синоним \a unite().
|
||||
PISet<T> & operator+=(const PISet<T> & v) { return unite(v); }
|
||||
|
||||
//! Unite set with "v"
|
||||
//! \~english Same as \a unite().
|
||||
//! \~russian Синоним \a unite().
|
||||
PISet<T> & operator|=(const PISet<T> & v) { return unite(v); }
|
||||
|
||||
//! Subtract set with "v"
|
||||
//! \~english Same as \a subtract().
|
||||
//! \~russian Синоним \a subtract().
|
||||
PISet<T> & operator-=(const PISet<T> & v) { return subtract(v); }
|
||||
|
||||
//! Intersect set with "v"
|
||||
//! \~english Same as \a intersect().
|
||||
//! \~russian Синоним \a intersect().
|
||||
PISet<T> & operator&=(const PISet<T> & v) { return intersect(v); }
|
||||
|
||||
//! Returns content of set as PIVector
|
||||
//! \~english Returns set contents as \a PIVector.
|
||||
//! \~russian Возвращает содержимое множества в виде \a PIVector.
|
||||
PIVector<T> toVector() const {
|
||||
PIVector<T> ret;
|
||||
for (const auto & i: *this)
|
||||
@@ -238,7 +352,8 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! Returns content of set as PIDeque
|
||||
//! \~english Returns set contents as \a PIDeque.
|
||||
//! \~russian Возвращает содержимое множества в виде \a PIDeque.
|
||||
PIDeque<T> toDeque() const {
|
||||
PIDeque<T> ret;
|
||||
for (const auto & i: *this)
|
||||
@@ -248,7 +363,9 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! \relatesalso PISet \brief Returns unite of two sets
|
||||
//! \relatesalso PISet
|
||||
//! \~english Returns union of two sets.
|
||||
//! \~russian Возвращает объединение двух множеств.
|
||||
template<typename T>
|
||||
PISet<T> operator+(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
PISet<T> ret(v0);
|
||||
@@ -256,7 +373,9 @@ PISet<T> operator+(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \relatesalso PISet \brief Returns subtraction of two sets
|
||||
//! \relatesalso PISet
|
||||
//! \~english Returns difference of two sets.
|
||||
//! \~russian Возвращает разность двух множеств.
|
||||
template<typename T>
|
||||
PISet<T> operator-(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
PISet<T> ret(v0);
|
||||
@@ -264,7 +383,9 @@ PISet<T> operator-(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \relatesalso PISet \brief Returns unite of two sets
|
||||
//! \relatesalso PISet
|
||||
//! \~english Returns union of two sets.
|
||||
//! \~russian Возвращает объединение двух множеств.
|
||||
template<typename T>
|
||||
PISet<T> operator|(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
PISet<T> ret(v0);
|
||||
@@ -272,7 +393,9 @@ PISet<T> operator|(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \relatesalso PISet \brief Returns intersetion of two sets
|
||||
//! \relatesalso PISet
|
||||
//! \~english Returns intersection of two sets.
|
||||
//! \~russian Возвращает пересечение двух множеств.
|
||||
template<typename T>
|
||||
PISet<T> operator&(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
PISet<T> ret(v0);
|
||||
@@ -281,6 +404,9 @@ PISet<T> operator&(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
}
|
||||
|
||||
|
||||
//! \relatesalso PISet
|
||||
//! \~english Output operator to \a PICout.
|
||||
//! \~russian Оператор вывода в \a PICout.
|
||||
template<typename Type>
|
||||
inline PICout operator<<(PICout s, const PISet<Type> & v) {
|
||||
s.space();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \file pistack.h
|
||||
//! \~\file pistack.h
|
||||
//! \brief
|
||||
//! \~english Declares \a PIStack
|
||||
//! \~russian Объявление \a PIStack
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \file pivector.h
|
||||
//! \~\file pivector.h
|
||||
//! \brief
|
||||
//! \~english Declares \a PIVector
|
||||
//! \~russian Объявление \a PIVector
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
/*! \file pivector2d.h
|
||||
* \brief 2D wrapper around PIVector
|
||||
*
|
||||
* This file declares PIVector2D
|
||||
*/
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \~\file pivector2d.h
|
||||
//! \brief
|
||||
//! \~english Declares \a PIVector2D
|
||||
//! \~russian Объявление \a PIVector2D
|
||||
//! \~\authors
|
||||
//! \~english
|
||||
//! Andrey Bychkov work.a.b@yandex.ru;
|
||||
//! \~russian
|
||||
//! Андрей Бычков work.a.b@yandex.ru;
|
||||
//! \~\}
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
2D wrapper around PIVector
|
||||
|
||||
Reference in New Issue
Block a user