CleanUp usage of QtAlgorithms

Change-Id: I61be20554014f90c2e1313167a3e3c869e26c35e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Nikita Baryshnikov
2014-06-16 21:34:13 +04:00
committed by hjk
parent 453bb4ebe5
commit 84e176edab
12 changed files with 25 additions and 46 deletions

View File

@@ -36,7 +36,6 @@
#include <QtCore/QByteArray> #include <QtCore/QByteArray>
#include <QtCore/QVector> #include <QtCore/QVector>
#include <QtCore/QSharedData> #include <QtCore/QSharedData>
#include <QtAlgorithms>
#ifdef DEBUG_UNIT_COUNT #ifdef DEBUG_UNIT_COUNT
# include <QAtomicInt> # include <QAtomicInt>

View File

@@ -72,7 +72,6 @@
#include <QRegExp> #include <QRegExp>
#include <QTextStream> #include <QTextStream>
#include <QTimer> #include <QTimer>
#include <QtAlgorithms>
#include <QStack> #include <QStack>
#include <QApplication> #include <QApplication>
@@ -6417,7 +6416,7 @@ void FakeVimHandler::Private::indentText(const Range &range, QChar typedChar)
int beginBlock = document()->findBlock(range.beginPos).blockNumber(); int beginBlock = document()->findBlock(range.beginPos).blockNumber();
int endBlock = document()->findBlock(range.endPos).blockNumber(); int endBlock = document()->findBlock(range.endPos).blockNumber();
if (beginBlock > endBlock) if (beginBlock > endBlock)
qSwap(beginBlock, endBlock); std::swap(beginBlock, endBlock);
// Don't remember current indentation in last text insertion. // Don't remember current indentation in last text insertion.
const QString lastInsertion = m_buffer->lastInsertion; const QString lastInsertion = m_buffer->lastInsertion;
@@ -6438,7 +6437,7 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
int endLine = lineForPosition(position()); int endLine = lineForPosition(position());
int targetPos = anchor(); int targetPos = anchor();
if (beginLine > endLine) { if (beginLine > endLine) {
qSwap(beginLine, endLine); std::swap(beginLine, endLine);
targetPos = position(); targetPos = position();
} }
if (hasConfig(ConfigStartOfLine)) if (hasConfig(ConfigStartOfLine))

View File

@@ -46,7 +46,6 @@
#include <QShortcut> #include <QShortcut>
#include <QSignalMapper> #include <QSignalMapper>
#include <QStringList> #include <QStringList>
#include <QtAlgorithms>
using namespace Core; using namespace Core;

View File

@@ -53,7 +53,6 @@
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/editorconfiguration.h> #include <projectexplorer/editorconfiguration.h>
#include <QtAlgorithms>
#include <QPointer> #include <QPointer>
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>

View File

@@ -40,7 +40,6 @@
#include <QDebug> #include <QDebug>
#include <QMessageBox> #include <QMessageBox>
#include <QtAlgorithms>
enum { enum {
debug = false debug = false

View File

@@ -30,7 +30,6 @@
#include "qmljshighlighter.h" #include "qmljshighlighter.h"
#include <QSet> #include <QSet>
#include <QtAlgorithms>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>

View File

@@ -60,7 +60,6 @@
#include <QTextStream> #include <QTextStream>
#include <QTimer> #include <QTimer>
#include <QRegExp> #include <QRegExp>
#include <QtAlgorithms>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <qglobal.h> #include <qglobal.h>

View File

@@ -280,7 +280,7 @@ bool BasicProposalItemListModel::isSortable(const QString &prefix) const
void BasicProposalItemListModel::sort(const QString &prefix) void BasicProposalItemListModel::sort(const QString &prefix)
{ {
qStableSort(m_currentItems.begin(), m_currentItems.end(), ContentLessThan(prefix)); std::stable_sort(m_currentItems.begin(), m_currentItems.end(), ContentLessThan(prefix));
} }
int BasicProposalItemListModel::persistentId(int index) const int BasicProposalItemListModel::persistentId(int index) const

View File

@@ -41,7 +41,6 @@
#include <QDir> #include <QDir>
#include <QDebug> #include <QDebug>
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <QtAlgorithms>
#include <iterator> #include <iterator>
#include <algorithm> #include <algorithm>
@@ -51,29 +50,16 @@ using namespace Internal;
namespace { namespace {
struct SnippetComp static bool snippetComp(const Snippet &a, const Snippet &b)
{ {
bool operator()(const Snippet &a, const Snippet &b) const const int comp = a.trigger().toLower().localeAwareCompare(b.trigger().toLower());
{ if (comp < 0)
const int comp = a.trigger().toLower().localeAwareCompare(b.trigger().toLower()); return true;
if (comp < 0) else if (comp == 0 &&
return true; a.complement().toLower().localeAwareCompare(b.complement().toLower()) < 0)
else if (comp == 0 && return true;
a.complement().toLower().localeAwareCompare(b.complement().toLower()) < 0) return false;
return true; }
return false;
}
};
SnippetComp snippetComp;
struct RemovedSnippetPred
{
bool operator()(const Snippet &s) const
{
return s.isRemoved();
}
};
RemovedSnippetPred removedSnippetPred;
} // Anonymous } // Anonymous
@@ -140,8 +126,8 @@ SnippetsCollection::Hint SnippetsCollection::computeInsertionHint(const Snippet
{ {
const int group = groupIndex(snippet.groupId()); const int group = groupIndex(snippet.groupId());
QList<Snippet> &snippets = m_snippets[group]; QList<Snippet> &snippets = m_snippets[group];
QList<Snippet>::iterator it = qUpperBound( QList<Snippet>::iterator it = std::upper_bound(snippets.begin(), m_activeSnippetsEnd.at(group),
snippets.begin(), m_activeSnippetsEnd.at(group), snippet, snippetComp); snippet, snippetComp);
return Hint(static_cast<int>(std::distance(snippets.begin(), it)), it); return Hint(static_cast<int>(std::distance(snippets.begin(), it)), it);
} }
@@ -175,12 +161,12 @@ SnippetsCollection::Hint SnippetsCollection::computeReplacementHint(int index,
{ {
const int group = groupIndex(snippet.groupId()); const int group = groupIndex(snippet.groupId());
QList<Snippet> &snippets = m_snippets[group]; QList<Snippet> &snippets = m_snippets[group];
QList<Snippet>::iterator it = qLowerBound( QList<Snippet>::iterator it = std::lower_bound(snippets.begin(), m_activeSnippetsEnd.at(group),
snippets.begin(), m_activeSnippetsEnd.at(group), snippet, snippetComp); snippet, snippetComp);
int hintIndex = static_cast<int>(std::distance(snippets.begin(), it)); int hintIndex = static_cast<int>(std::distance(snippets.begin(), it));
if (index < hintIndex - 1) if (index < hintIndex - 1)
return Hint(hintIndex - 1, it); return Hint(hintIndex - 1, it);
it = qUpperBound(it, m_activeSnippetsEnd.at(group), snippet, snippetComp); it = std::upper_bound(it, m_activeSnippetsEnd.at(group), snippet, snippetComp);
hintIndex = static_cast<int>(std::distance(snippets.begin(), it)); hintIndex = static_cast<int>(std::distance(snippets.begin(), it));
if (index > hintIndex) if (index > hintIndex)
return Hint(hintIndex, it); return Hint(hintIndex, it);
@@ -249,7 +235,7 @@ void SnippetsCollection::updateActiveSnippetsEnd(int groupIndex)
{ {
m_activeSnippetsEnd[groupIndex] = std::find_if(m_snippets[groupIndex].begin(), m_activeSnippetsEnd[groupIndex] = std::find_if(m_snippets[groupIndex].begin(),
m_snippets[groupIndex].end(), m_snippets[groupIndex].end(),
removedSnippetPred); [](const Snippet &s) { return s.isRemoved(); });
} }
void SnippetsCollection::restoreRemovedSnippets(const QString &groupId) void SnippetsCollection::restoreRemovedSnippets(const QString &groupId)
@@ -258,7 +244,7 @@ void SnippetsCollection::restoreRemovedSnippets(const QString &groupId)
// Reverting the snippet can still bring it to the original version // Reverting the snippet can still bring it to the original version
const int group = groupIndex(groupId); const int group = groupIndex(groupId);
QVector<Snippet> toRestore(std::distance(m_activeSnippetsEnd[group], m_snippets[group].end())); QVector<Snippet> toRestore(std::distance(m_activeSnippetsEnd[group], m_snippets[group].end()));
qCopy(m_activeSnippetsEnd[group], m_snippets[group].end(), toRestore.begin()); std::copy(m_activeSnippetsEnd[group], m_snippets[group].end(), toRestore.begin());
m_snippets[group].erase(m_activeSnippetsEnd[group], m_snippets[group].end()); m_snippets[group].erase(m_activeSnippetsEnd[group], m_snippets[group].end());
foreach (Snippet snippet, toRestore) { foreach (Snippet snippet, toRestore) {
snippet.setIsRemoved(false); snippet.setIsRemoved(false);

View File

@@ -38,7 +38,7 @@
#include <QTextStream> #include <QTextStream>
#include <QVector> #include <QVector>
#include <QtAlgorithms> #include <algorithm>
namespace Valgrind { namespace Valgrind {
namespace XmlProtocol { namespace XmlProtocol {
@@ -95,7 +95,7 @@ Error::Error(const Error &other) :
void Error::swap(Error &other) void Error::swap(Error &other)
{ {
qSwap(d, other.d); std::swap(d, other.d);
} }
Error &Error::operator=(const Error &other) Error &Error::operator=(const Error &other)

View File

@@ -31,7 +31,8 @@
#include "frame.h" #include "frame.h"
#include <QString> #include <QString>
#include <QtAlgorithms>
#include <algorithm>
namespace Valgrind { namespace Valgrind {
namespace XmlProtocol { namespace XmlProtocol {
@@ -91,7 +92,7 @@ bool Frame::operator!=(const Frame &other) const
void Frame::swap(Frame &other) void Frame::swap(Frame &other)
{ {
qSwap(d, other.d); std::swap(d, other.d);
} }
quint64 Frame::instructionPointer() const quint64 Frame::instructionPointer() const

View File

@@ -34,7 +34,6 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QDebug> #include <QDebug>
#include <QtAlgorithms>
#include <QRegExp> #include <QRegExp>
/*! /*!
@@ -82,7 +81,7 @@ enum FoldingState {
Location Location
}; };
}; // namespace Internal; } // namespace Internal;
static inline QTextCharFormat invertedColorFormat(const QTextCharFormat &in) static inline QTextCharFormat invertedColorFormat(const QTextCharFormat &in)
{ {