add doxygen via opencode
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
/*! \file piset.h
|
||||
* \brief Set container
|
||||
*
|
||||
* This file declare PISet
|
||||
*/
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \file piset.h
|
||||
//! \brief
|
||||
//! \~english Declares \a PISet
|
||||
//! \~russian Объявление \a PISet
|
||||
//! \~\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
|
||||
Set container
|
||||
@@ -27,13 +36,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 A set is a collection of unique elements.
|
||||
//! \~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 +72,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 with one element `value`.
|
||||
//! \~russian Создает множество с одним элементом `value`.
|
||||
explicit PISet(const T & value) { _CSet::insert(value, 0); }
|
||||
|
||||
//! Contructs set with elements "v0" and "v1"
|
||||
//! \~english Constructs a set with two elements `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 with three elements `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 with four elements `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);
|
||||
@@ -154,7 +188,8 @@ public:
|
||||
inline const_iterator begin() const { return const_iterator(this, 0); }
|
||||
inline const_iterator end() const { return const_iterator(this, _CSet::size()); }
|
||||
|
||||
//! Contructs set from vector of elements
|
||||
//! \~english Constructs a set from a vector of elements.
|
||||
//! \~russian Создает множество из вектора элементов.
|
||||
explicit PISet(const PIVector<T> & values) {
|
||||
if (values.isEmpty()) return;
|
||||
for (int i = 0; i < values.size_s(); ++i) {
|
||||
@@ -162,7 +197,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//! Contructs set from deque of elements
|
||||
//! \~english Constructs a set from a deque of elements.
|
||||
//! \~russian Создает множество из deque элементов.
|
||||
explicit PISet(const PIDeque<T> & values) {
|
||||
if (values.isEmpty()) return;
|
||||
for (int i = 0; i < values.size_s(); ++i) {
|
||||
@@ -172,6 +208,8 @@ public:
|
||||
|
||||
typedef T key_type;
|
||||
|
||||
//! \~english Inserts element `t` into the set.
|
||||
//! \~russian Вставляет элемент `t` в множество.
|
||||
PISet<T> & operator<<(const T & t) {
|
||||
_CSet::insert(t, 0);
|
||||
return *this;
|
||||
@@ -185,52 +223,62 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Tests if element `key` exists in the set.
|
||||
//! \~russian Проверяет наличие элемента `key` в массиве.
|
||||
//! \~english Tests if 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 Tests if 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 Returns the union of this set with set `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 Returns the difference of this set and set `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 Returns the intersection of this set with set `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 Returns the union of this set with set `v`.
|
||||
//! \~russian Возвращает объединение этого множества с множеством `v`.
|
||||
PISet<T> & operator+=(const PISet<T> & v) { return unite(v); }
|
||||
|
||||
//! Unite set with "v"
|
||||
//! \~english Returns the union of this set with set `v`.
|
||||
//! \~russian Возвращает объединение этого множества с множеством `v`.
|
||||
PISet<T> & operator|=(const PISet<T> & v) { return unite(v); }
|
||||
|
||||
//! Subtract set with "v"
|
||||
//! \~english Returns the difference of this set and set `v`.
|
||||
//! \~russian Возвращает разность этого множества и множества `v`.
|
||||
PISet<T> & operator-=(const PISet<T> & v) { return subtract(v); }
|
||||
|
||||
//! Intersect set with "v"
|
||||
//! \~english Returns the intersection of this set with set `v`.
|
||||
//! \~russian Возвращает пересечение этого множества с множеством `v`.
|
||||
PISet<T> & operator&=(const PISet<T> & v) { return intersect(v); }
|
||||
|
||||
//! Returns content of set as PIVector
|
||||
//! \~english Converts the set to a vector.
|
||||
//! \~russian Преобразует множество в вектор.
|
||||
PIVector<T> toVector() const {
|
||||
PIVector<T> ret;
|
||||
for (const auto & i: *this)
|
||||
@@ -238,7 +286,8 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! Returns content of set as PIDeque
|
||||
//! \~english Converts the set to a deque.
|
||||
//! \~russian Преобразует множество в deque.
|
||||
PIDeque<T> toDeque() const {
|
||||
PIDeque<T> ret;
|
||||
for (const auto & i: *this)
|
||||
@@ -248,7 +297,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! \relatesalso PISet \brief Returns unite of two sets
|
||||
//! \~english Returns the 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 +306,8 @@ PISet<T> operator+(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \relatesalso PISet \brief Returns subtraction of two sets
|
||||
//! \~english Returns the 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 +315,8 @@ PISet<T> operator-(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \relatesalso PISet \brief Returns unite of two sets
|
||||
//! \~english Returns the 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 +324,8 @@ PISet<T> operator|(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \relatesalso PISet \brief Returns intersetion of two sets
|
||||
//! \~english Returns the 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 +334,9 @@ PISet<T> operator&(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
}
|
||||
|
||||
|
||||
//! \relatesalso PICout
|
||||
//! \~english Output operator to \a PICout
|
||||
//! \~russian Оператор вывода в \a PICout
|
||||
template<typename Type>
|
||||
inline PICout operator<<(PICout s, const PISet<Type> & v) {
|
||||
s.space();
|
||||
@@ -297,4 +353,6 @@ inline PICout operator<<(PICout s, const PISet<Type> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \}
|
||||
|
||||
#endif // PISET_H
|
||||
|
||||
@@ -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