pimap some doc

This commit is contained in:
Бычков Андрей
2022-08-30 18:15:13 +03:00
parent 3511fee459
commit db3de9904a
3 changed files with 31 additions and 5 deletions

View File

@@ -2082,9 +2082,9 @@ public:
}
//! \~english Returns a new array with all elements
//! that pass the test implemented by the provided function `test`.
//! that pass the test implemented by the provided function `bool test(const T & e)`.
//! \~russian Возвращает новый массив со всеми элементами,
//! прошедшими проверку, задаваемую в передаваемой функции `test`.
//! прошедшими проверку, задаваемую в передаваемой функции `bool test(const T & e)`.
//! \~\details
//! \~\code
//! PIDeque<int> v{3, 2, 5, 2, 7};

View File

@@ -1,6 +1,6 @@
//! \addtogroup Containers
//! \{
//! \file pideque.h
//! \file pimap.h
//! \brief
//! \~english Declares \a PIMap
//! \~russian Объявление \a PIMap
@@ -435,6 +435,11 @@ public:
pim_index.swap(other.pim_index);
}
//! \~english Inserts value `value` with key `key` in the array.
//! \~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`.
inline PIMap<Key, T> & insert(const Key & key, const T & value) {
bool f(false);
ssize_t i = _find(key, f);
@@ -459,6 +464,11 @@ public:
return *this;
}
//! \~english Inserts value `pair` in the array.
//! \~russian Вставляет пару `pair` в массив.
//! \~\details
//! \~english The first element of the pair is the key, and the second is the value.
//! \~russian Первый элемент пары является ключом, а второй значением.
inline PIMap<Key, T> & insert(const PIPair<Key, T> & pair) {
bool f(false);
ssize_t i = _find(pair.first, f);
@@ -511,6 +521,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)` для каждого элемента массива.
inline void forEach(std::function<void(const Key & key, const T & value)> f) const {
for (int i = 0; i < pim_index.size_s(); ++i) {
f(pim_index[i].key, pim_content[pim_index[i].index]);
@@ -535,6 +547,20 @@ public:
return ret;
}
//! \~english Returns a new array with all elements
//! that pass the test implemented by the provided function `bool test(const Key & key, const T & value)`.
//! \~russian Возвращает новый массив со всеми элементами,
//! прошедшими проверку, задаваемую в передаваемой функции `bool test(const Key & key, const T & value)`.
inline PIDeque<T> filter(std::function<bool(const Key & key, const T & value)> test) const {
PIMap<Key, T> ret;
for (int i = 0; i < pim_index.size_s(); ++i) {
if (test(pim_index[i].key, pim_content[pim_index[i].index])) {
ret.insert(pim_index[i].key, pim_content[pim_index[i].index]);
}
}
return ret;
}
private:
struct MapIndex {
MapIndex(const Key & k = Key(), size_t i = 0): key(k), index(i) {}

View File

@@ -2000,9 +2000,9 @@ public:
}
//! \~english Returns a new array with all elements
//! that pass the test implemented by the provided function `test`.
//! that pass the test implemented by the provided function `bool test(const T & e)`.
//! \~russian Возвращает новый массив со всеми элементами,
//! прошедшими проверку, задаваемую в передаваемой функции `test`.
//! прошедшими проверку, задаваемую в передаваемой функции `bool test(const T & e)`.
//! \~\details
//! \~\code
//! PIVector<int> v{3, 2, 5, 2, 7};