merged AI doc, some new pages
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user