doc PIMap PIStack PIQueue done
This commit is contained in:
@@ -494,6 +494,10 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Returns the value of the element by the key `key`
|
||||
//! or `default_` if there is no such element.
|
||||
//! \~russian Возвращает значение элемента по ключу `key`
|
||||
//! или `default_` если такого элемента нет.
|
||||
inline T value(const Key & key, const T & default_ = T()) const {
|
||||
bool f(false);
|
||||
ssize_t i = _find(key, f);
|
||||
@@ -501,17 +505,25 @@ public:
|
||||
return pim_content[pim_index[i].index];
|
||||
}
|
||||
|
||||
//! \~english Returns an array of values of all elements
|
||||
//! \~russian Возвращает массив значений всех эелметнов
|
||||
inline PIVector<T> values() const {return pim_content;}
|
||||
|
||||
inline Key key(const T & value_, const Key & default_ = Key()) const {
|
||||
//! \~english Returns the key of the first element
|
||||
//! whose value matches `value` or `default_` if there is no such element.
|
||||
//! \~russian Возвращает ключ первого элемента, значение которого
|
||||
//! совпадает с `value` или `default_` если такого элемента нет.
|
||||
inline Key key(const T & value, const Key & default_ = Key()) const {
|
||||
for (int i = 0; i < pim_index.size_s(); ++i) {
|
||||
if (pim_content[pim_index[i].index] == value_) {
|
||||
if (pim_content[pim_index[i].index] == value) {
|
||||
return pim_index[i].key;
|
||||
}
|
||||
}
|
||||
return default_;
|
||||
}
|
||||
|
||||
//! \~english Returns an array of keys of all elements
|
||||
//! \~russian Возвращает массив ключей всех элементов
|
||||
inline PIVector<Key> keys() const {
|
||||
PIVector<Key> ret;
|
||||
ret.reserve(pim_index.size());
|
||||
@@ -529,6 +541,10 @@ 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)` для каждого элемента массива.
|
||||
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; ret.reserve(size());
|
||||
@@ -538,6 +554,10 @@ 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)` для каждого элемента массива.
|
||||
template <typename ST>
|
||||
inline PIVector<ST> map(std::function<ST(const Key & key, const T & value)> f) const {
|
||||
PIVector<ST> ret; ret.reserve(size());
|
||||
@@ -551,7 +571,7 @@ public:
|
||||
//! 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 {
|
||||
inline PIMap<Key, 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])) {
|
||||
|
||||
Reference in New Issue
Block a user