From cba6db4f3897bbec3076991a332a418960fe5ce7 Mon Sep 17 00:00:00 2001 From: andrey Date: Wed, 4 Aug 2021 11:00:39 +0300 Subject: [PATCH] doc rename --- doc/examples/pievaluator.cpp | 6 +- libs/main/containers/pimap.cpp | 187 +++++++++++++++ .../{picontainers.cpp => pivector.cpp} | 213 +----------------- 3 files changed, 191 insertions(+), 215 deletions(-) create mode 100644 libs/main/containers/pimap.cpp rename libs/main/containers/{picontainers.cpp => pivector.cpp} (54%) diff --git a/doc/examples/pievaluator.cpp b/doc/examples/pievaluator.cpp index 901ac054..c834f319 100644 --- a/doc/examples/pievaluator.cpp +++ b/doc/examples/pievaluator.cpp @@ -4,10 +4,10 @@ void _() { //! [main] PIEvaluator eval; -eval.check("e2eelge"); +eval.check("2*sin(pi/2)"); -piCout << eval.expression() << "=" << eval.evaluate(); -// e*2*e*e*lg(e) = (17.4461; 0) +piCout << eval.expression() << "=" << eval.evaluate().real(); +// 2*sin(pi/2) = 2 eval.check("10x"); diff --git a/libs/main/containers/pimap.cpp b/libs/main/containers/pimap.cpp new file mode 100644 index 00000000..3c0b0034 --- /dev/null +++ b/libs/main/containers/pimap.cpp @@ -0,0 +1,187 @@ +/** \class PIMap + * \brief Associative array + * \details This class used to store Key = Value array of any + * type of data. \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(). + + * \fn PIMap::PIMap(); + * \brief Contructs an empty map + + * \fn PIMap::PIMap(const PIMap & other); + * \brief Contructs a copy of "other" + + * \fn PIMap & PIMap::operator =(const PIMap & other); + * \brief Copy operator + + * \fn PIMap::PIMap(const PIMap & other); + * \brief Contructs a copy of "other" + +* \fn PIMapIterator PIMap::makeIterator() const +* \brief Returns PIMapIterator for this map + +* \fn PIMapIterator PIMap::makeReverseIterator() const +* \brief Returns reverse PIMapIterator for this map + + +* \fn size_t PIMap::size() const +* \brief Returns entries count + +* \fn int PIMap::size_s() const +* \brief Returns entries count + +* \fn size_t PIMap::length() const +* \brief Returns entries count + +* \fn bool PIMap::isEmpty() const +* \brief Returns if map is empty + + +* \fn T & PIMap::operator [](const Key & key) +* \brief Returns value for key "key". If there is no key in map, create one. + +* \fn const T PIMap::operator [](const Key & key) const +* \brief Returns value for key "key". If there is no key in map, returns default T(). + +* \fn T & PIMap::at(const Key & key) +* \brief Equivalent to operator [] + +* \fn const T PIMap::at(const Key & key) const +* \brief Equivalent to operator [] + + +* \fn PIMap & PIMap::operator <<(const PIMap & other) +* \brief Insert all etries of "other" to this map. Override existing values. + +* \fn bool PIMap::operator ==(const PIMap & t) const +* \brief Compare operator + +* \fn bool PIMap::operator !=(const PIMap & t) const +* \brief Compare operator + +* \fn bool PIMap::contains(const Key & key) const +* \brief Returns "true" if map contains entry with key "key" + + +* \fn PIMap & PIMap::reserve(size_t new_size) +* \brief Reserve space for "new_size" entries + +* \fn PIMap & PIMap::removeOne(const Key & key) +* \brief Remove entry with key "key" + +* \fn PIMap & PIMap::remove(const Key & key) +* \brief Equivalent \a removeOne(key) + +* \fn PIMap & PIMap::erase(const Key & key) +* \brief Equivalent \a removeOne(key) + +* \fn PIMap & PIMap::clear() +* \brief Clear map + + +* \fn void PIMap::swap(PIMap & other) +* \brief Swap map with "other" + + +* \fn PIMap & PIMap::insert(const Key & key, const T & value) +* \brief Insert or rewrite entry with key "key" and value "value" + +* \fn const T PIMap::value(const Key & key, const T & default = T()) +* \brief Returns value for key "key". If there is no key in map, returns "default". + +* \fn PIVector PIMap::values() const +* \brief Returns all values as PIVector + +* \fn Key PIMap::key(const T & value, const Key & default = Key()) const +* \brief Returns key for first founded value "value". If there is no such value in map, returns "default". + +* \fn PIVector PIMap::keys() const +* \brief Returns all keys as PIVector + + * */ + + + + +/** \class PIMapIterator + * \brief Helper class to iterate over PIMap + * \details This class used to access keys and values in PIMap. + * You can use constructor to create iterator, or use \a PIMap::makeIterator() + * and \a PIMap::makeReverseIterator() methods. + * + * First usage variant: + * \code + * PIMap m; + * m[1] = "one"; + * m[2] = "two"; + * m[4] = "four"; + * + * auto it = m.makeIterator(); + * while (it.next()) { + * piCout << it.key() << it.value(); + * } + * // 1 one + * // 2 two + * // 4 four + * \endcode + * + * Using hasNext(): + * \code + * while (it.hasNext()) { + * it.next(); + * \endcode + * + * Using constructor: + * \code + * PIMapIterator it(m); + * \endcode + * + * Write access: + * \code + * while (it.next()) { + * it.valueRef().append("_!"); + * piCout << it.key() << it.value(); + * } + * + * // 1 one_! + * // 2 two_! + * // 4 four_! + * \endcode + * + * Reverse iterator: + * \code + * auto it = m.makeReverseIterator(); + * while (it.next()) { + * piCout << it.key() << it.value(); + * } + * + * // 4 four + * // 2 two + * // 1 one + * \endcode + +* \fn PIMapIterator(const PIMap & map, bool reverse = false) +* \brief Contructs iterator for "map". Current position is invalid. + +* \fn const Key & PIMapIterator::key() const +* \brief Returns current entry key + +* \fn const T & PIMapIterator::value() const +* \brief Returns current entry value + +* \fn T & PIMapIterator::valueRef() const +* \brief Returns reference to current entry value + +* \fn bool PIMapIterator::hasNext() +* \brief Returns if iterator can jump to next entry + +* \fn bool PIMapIterator::next() +* \brief Jump to next entry and return if new position is valid. + +* \fn void PIMapIterator::reset() +* \brief Reset iterator to initial position. + + * */ diff --git a/libs/main/containers/picontainers.cpp b/libs/main/containers/pivector.cpp similarity index 54% rename from libs/main/containers/picontainers.cpp rename to libs/main/containers/pivector.cpp index 823cd5c4..3c7a96fd 100644 --- a/libs/main/containers/picontainers.cpp +++ b/libs/main/containers/pivector.cpp @@ -1,23 +1,3 @@ -/* - PIP - Platform Independent Primitives - Generic containers - Ivan Pelipenko peri4ko@yandex.ru - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -*/ - - /** \class PIVector * \brief Dynamic array of any type * \details This class used to store dynamic array of any @@ -94,7 +74,7 @@ * \fn PIVector & PIVector::sort(CompareFunc compare = compare_func); * \brief Sort vector using quick sort algorithm and standard compare function - * \details Example: \snippet picontainers.cpp PIVector::sort_0 + * \details Example: \snippet picontainers.cpp PIVector::sort_0 * With custom compare function: \snippet picontainers.cpp PIVector::sort_1 * \fn PIVector & PIVector::fill(const T & t); @@ -188,194 +168,3 @@ * \brief Compare with vector "t" * */ - - - - -/** \class PIMap - * \brief Associative array - * \details This class used to store Key = Value array of any - * type of data. \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(). - - * \fn PIMap::PIMap(); - * \brief Contructs an empty map - - * \fn PIMap::PIMap(const PIMap & other); - * \brief Contructs a copy of "other" - - * \fn PIMap & PIMap::operator =(const PIMap & other); - * \brief Copy operator - - * \fn PIMap::PIMap(const PIMap & other); - * \brief Contructs a copy of "other" - -* \fn PIMapIterator PIMap::makeIterator() const -* \brief Returns PIMapIterator for this map - -* \fn PIMapIterator PIMap::makeReverseIterator() const -* \brief Returns reverse PIMapIterator for this map - - -* \fn size_t PIMap::size() const -* \brief Returns entries count - -* \fn int PIMap::size_s() const -* \brief Returns entries count - -* \fn size_t PIMap::length() const -* \brief Returns entries count - -* \fn bool PIMap::isEmpty() const -* \brief Returns if map is empty - - -* \fn T & PIMap::operator [](const Key & key) -* \brief Returns value for key "key". If there is no key in map, create one. - -* \fn const T PIMap::operator [](const Key & key) const -* \brief Returns value for key "key". If there is no key in map, returns default T(). - -* \fn T & PIMap::at(const Key & key) -* \brief Equivalent to operator [] - -* \fn const T PIMap::at(const Key & key) const -* \brief Equivalent to operator [] - - -* \fn PIMap & PIMap::operator <<(const PIMap & other) -* \brief Insert all etries of "other" to this map. Override existing values. - -* \fn bool PIMap::operator ==(const PIMap & t) const -* \brief Compare operator - -* \fn bool PIMap::operator !=(const PIMap & t) const -* \brief Compare operator - -* \fn bool PIMap::contains(const Key & key) const -* \brief Returns "true" if map contains entry with key "key" - - -* \fn PIMap & PIMap::reserve(size_t new_size) -* \brief Reserve space for "new_size" entries - -* \fn PIMap & PIMap::removeOne(const Key & key) -* \brief Remove entry with key "key" - -* \fn PIMap & PIMap::remove(const Key & key) -* \brief Equivalent \a removeOne(key) - -* \fn PIMap & PIMap::erase(const Key & key) -* \brief Equivalent \a removeOne(key) - -* \fn PIMap & PIMap::clear() -* \brief Clear map - - -* \fn void PIMap::swap(PIMap & other) -* \brief Swap map with "other" - - -* \fn PIMap & PIMap::insert(const Key & key, const T & value) -* \brief Insert or rewrite entry with key "key" and value "value" - -* \fn const T PIMap::value(const Key & key, const T & default = T()) -* \brief Returns value for key "key". If there is no key in map, returns "default". - -* \fn PIVector PIMap::values() const -* \brief Returns all values as PIVector - -* \fn Key PIMap::key(const T & value, const Key & default = Key()) const -* \brief Returns key for first founded value "value". If there is no such value in map, returns "default". - -* \fn PIVector PIMap::keys() const -* \brief Returns all keys as PIVector - - * */ - - - - -/** \class PIMapIterator - * \brief Helper class to iterate over PIMap - * \details This class used to access keys and values in PIMap. - * You can use constructor to create iterator, or use \a PIMap::makeIterator() - * and \a PIMap::makeReverseIterator() methods. - * - * First usage variant: - * \code - * PIMap m; - * m[1] = "one"; - * m[2] = "two"; - * m[4] = "four"; - * - * auto it = m.makeIterator(); - * while (it.next()) { - * piCout << it.key() << it.value(); - * } - * // 1 one - * // 2 two - * // 4 four - * \endcode - * - * Using hasNext(): - * \code - * while (it.hasNext()) { - * it.next(); - * \endcode - * - * Using constructor: - * \code - * PIMapIterator it(m); - * \endcode - * - * Write access: - * \code - * while (it.next()) { - * it.valueRef().append("_!"); - * piCout << it.key() << it.value(); - * } - * - * // 1 one_! - * // 2 two_! - * // 4 four_! - * \endcode - * - * Reverse iterator: - * \code - * auto it = m.makeReverseIterator(); - * while (it.next()) { - * piCout << it.key() << it.value(); - * } - * - * // 4 four - * // 2 two - * // 1 one - * \endcode - -* \fn PIMapIterator(const PIMap & map, bool reverse = false) -* \brief Contructs iterator for "map". Current position is invalid. - -* \fn const Key & PIMapIterator::key() const -* \brief Returns current entry key - -* \fn const T & PIMapIterator::value() const -* \brief Returns current entry value - -* \fn T & PIMapIterator::valueRef() const -* \brief Returns reference to current entry value - -* \fn bool PIMapIterator::hasNext() -* \brief Returns if iterator can jump to next entry - -* \fn bool PIMapIterator::next() -* \brief Jump to next entry and return if new position is valid. - -* \fn void PIMapIterator::reset() -* \brief Reset iterator to initial position. - - * */