]> git.lyx.org Git - lyx.git/commitdiff
Use range-based loops
authorYuriy Skalko <yuriy.skalko@gmail.com>
Thu, 19 Nov 2020 12:03:26 +0000 (14:03 +0200)
committerYuriy Skalko <yuriy.skalko@gmail.com>
Sat, 21 Nov 2020 18:32:16 +0000 (20:32 +0200)
12 files changed:
src/KeyMap.cpp
src/LyXAction.cpp
src/LyXAction.h
src/frontends/qt/GuiCommandBuffer.cpp
src/frontends/qt/qt_helpers.cpp
src/insets/ExternalSupport.cpp
src/insets/InsetInclude.cpp
src/insets/InsetInfo.cpp
src/insets/InsetLabel.cpp
src/mathed/MathData.cpp
src/output_latex.cpp
src/support/lyxalgo.h

index 3698ddb64254d421bb619eb3408f009c82cf0fe9..f469da5c44d0326a55f945b2045e27bcd0989bbb 100644 (file)
@@ -531,10 +531,8 @@ KeyMap::BindingList KeyMap::listBindings(bool unbound, KeyMap::ItemType tag) con
        BindingList list;
        listBindings(list, KeySequence(nullptr, nullptr), tag);
        if (unbound) {
-               LyXAction::const_iterator fit = lyxaction.func_begin();
-               LyXAction::const_iterator const fen = lyxaction.func_end();
-               for (; fit != fen; ++fit) {
-                       FuncCode action = fit->second;
+               for (auto const & name_code : lyxaction) {
+                       FuncCode action = name_code.second;
                        bool has_action = false;
                        BindingList::const_iterator bit = list.begin();
                        BindingList::const_iterator const ben = list.end();
index 8b13630d8688552b990ad00f5d158f1dc8b2b2c8..e1d78a012fd43fad6c7fbbdc784918263c71fe05 100644 (file)
@@ -4536,13 +4536,13 @@ bool LyXAction::funcHasFlag(FuncCode action,
 }
 
 
-LyXAction::const_iterator LyXAction::func_begin() const
+LyXAction::const_iterator LyXAction::begin() const
 {
        return lyx_func_map.begin();
 }
 
 
-LyXAction::const_iterator LyXAction::func_end() const
+LyXAction::const_iterator LyXAction::end() const
 {
        return lyx_func_map.end();
 }
index 30aeac03d7e7bae29c36309835748336432a4d01..000b0fb31c9199dc7f1f372fb4aa402c5221f71c 100644 (file)
@@ -94,10 +94,10 @@ public:
        typedef FuncMap::const_iterator const_iterator;
 
        /// return an iterator to the start of the list of LFUNs
-       const_iterator func_begin() const;
+       const_iterator begin() const;
 
        /// return an iterator to one past the end of the list of LFUNs
-       const_iterator func_end() const;
+       const_iterator end() const;
 
 private:
        /// noncopyable
index 06ca59ca0659e23e8592caf6f65f725fdabce676..d6334280ff879d4976682c6ed40b66764295fa05 100644 (file)
@@ -26,7 +26,6 @@
 #include "FuncRequest.h"
 #include "Session.h"
 
-#include "support/lyxalgo.h"
 #include "support/lstrings.h"
 
 #include <QHBoxLayout>
@@ -85,8 +84,9 @@ protected:
 GuiCommandBuffer::GuiCommandBuffer(GuiView * view)
        : view_(view)
 {
-       transform(lyxaction.func_begin(), lyxaction.func_end(),
-               back_inserter(commands_), firster());
+       for (auto const & name_code : lyxaction) {
+               commands_.push_back(name_code.first);
+       }
 
        QPixmap qpup = getPixmap("images/", "up", "svgz,png");
        QPixmap qpdown = getPixmap("images/", "down", "svgz,png");
@@ -263,18 +263,6 @@ void GuiCommandBuffer::hideParent()
 }
 
 
-namespace {
-
-class prefix_p {
-public:
-       string p;
-       prefix_p(string const & s) : p(s) {}
-       bool operator()(string const & s) const { return prefixIs(s, p); }
-};
-
-} // namespace
-
-
 string const GuiCommandBuffer::historyUp()
 {
        if (history_pos_ == history_.begin())
@@ -299,9 +287,10 @@ vector<string> const
 GuiCommandBuffer::completions(string const & prefix, string & new_prefix)
 {
        vector<string> comp;
-
-       lyx::copy_if(commands_.begin(), commands_.end(),
-               back_inserter(comp), prefix_p(prefix));
+       for (auto const & cmd : commands_) {
+               if (prefixIs(cmd, prefix))
+                       comp.push_back(cmd);
+       }
 
        if (comp.empty()) {
                new_prefix = prefix;
@@ -320,8 +309,10 @@ GuiCommandBuffer::completions(string const & prefix, string & new_prefix)
                test += tmp[test.length()];
        while (test.length() < tmp.length()) {
                vector<string> vtmp;
-               lyx::copy_if(comp.begin(), comp.end(),
-                       back_inserter(vtmp), prefix_p(test));
+               for (auto const & cmd : comp) {
+                       if (prefixIs(cmd, test))
+                               vtmp.push_back(cmd);
+               }
                if (vtmp.size() != comp.size()) {
                        test.erase(test.length() - 1);
                        break;
index dcac28f734a912a234ea365cb00287c2443dbddc..108d613042a2cf67f24f4acb37fcde73dfa807bc 100644 (file)
@@ -33,7 +33,6 @@
 #include "support/gettext.h"
 #include "support/Length.h"
 #include "support/lstrings.h"
-#include "support/lyxalgo.h"
 #include "support/os.h"
 #include "support/Package.h"
 #include "support/PathChanger.h"
index 3d7936abc77f68b22adc4b2f2e9a3ceb26d40f9c..24a228cb55edb1dc991aba50e2447f1f40ae557a 100644 (file)
@@ -30,7 +30,6 @@
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
-#include "support/lyxalgo.h"
 #include "support/os.h"
 #include "support/Package.h"
 
index 75a41c318148f7be6483cabaaccdd3869180b526..07f5eece56993cf01ccc8bd166e052c2f2c4af75 100644 (file)
@@ -61,7 +61,6 @@
 #include "support/gettext.h"
 #include "support/lassert.h"
 #include "support/lstrings.h" // contains
-#include "support/lyxalgo.h"
 #include "support/mutex.h"
 #include "support/ExceptionMessage.h"
 
index 981fa536be0a6db30d0fb494571290abe199aa32..2c72d9044a7752a20c11136ce46651008b03a155 100644 (file)
@@ -233,10 +233,8 @@ vector<pair<string,docstring>> InsetInfoParams::getArguments(Buffer const * buf,
        case MENU_INFO:
        case ICON_INFO: {
                result.push_back(make_pair("custom", _("Custom")));
-               LyXAction::const_iterator fit = lyxaction.func_begin();
-               LyXAction::const_iterator const fen = lyxaction.func_end();
-               for (; fit != fen; ++fit) {
-                       string const lfun = fit->first;
+               for (auto const & name_code : lyxaction) {
+                       string const lfun = name_code.first;
                        if (!lfun.empty())
                                result.push_back(make_pair(lfun, from_ascii(lfun)));
                }
index b624cce119d2d2976fb6a4f8b0c7725d24094ebc..73bc21f911325281c25be00501ca4c6f6f5379e8 100644 (file)
@@ -41,7 +41,6 @@
 #include "support/convert.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
-#include "support/lyxalgo.h"
 
 using namespace std;
 using namespace lyx::support;
index 53724303a9cc063407b38cd1e1ea2c4cf74bfff6..50fc100e6436eda63cf4de1a19b23cbee9172969 100644 (file)
@@ -37,7 +37,6 @@
 #include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
-#include "support/lyxalgo.h"
 
 #include <cstdlib>
 
index 1178a3b45954c1d5f192636816e2e7c1af3ffd11..8f8459ffa724baa01dff408732f284dc3d956403 100644 (file)
@@ -35,7 +35,6 @@
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/lstrings.h"
-#include "support/lyxalgo.h"
 #include "support/textutils.h"
 #include "support/gettext.h"
 
index 8bf8bbc54191ffd8c1450eea4918a459c8671625..8777a03e41d989160f3915304e759810316a9fa4 100644 (file)
 #ifndef LYX_ALGO_H
 #define LYX_ALGO_H
 
-#include <utility>
-#include <iterator>
-#include <algorithm>
-
-
 namespace lyx {
 
 
@@ -48,42 +43,6 @@ bool sorted(For first, For last, Cmp cmp)
 }
 
 
-struct firster {
-       template <class P1, class P2>
-       P1 operator()(std::pair<P1, P2> const & p) {
-               return p.first;
-       }
-};
-
-
-/**
- * copy elements in the given range to the output iterator
- * if the predicate evaluates as true
- */
-template <class InputIter, class OutputIter, class Func>
-OutputIter copy_if(InputIter first, InputIter last,
-              OutputIter result, Func func)
-{
-       for (; first != last; ++first) {
-               if (func(*first)) {
-                       *result++ = *first;
-               }
-       }
-       return result;
-}
-
-
-/// Remove all duplicate entries in c.
-template<class C>
-void eliminate_duplicates(C & c)
-{
-       // It is a requirement that the container is sorted for
-       // std::unique to work properly.
-       std::sort(c.begin(), c.end());
-       c.erase(std::unique(c.begin(), c.end()), c.end());
-}
-
-
 } // namespace lyx
 
 #endif // LYX_ALGO_H