Utils: Move set algorithms to Utils

So it can be used in other plugins which does not depend on clang.

Change-Id: I80b9f44609921951444e13c5fd35476c047ad579
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Marco Bubke
2020-11-05 12:15:58 +01:00
parent 938d9d919b
commit 6364692e15
9 changed files with 26 additions and 20 deletions

View File

@@ -156,7 +156,6 @@ HEADERS += \
$$PWD/refactoringserverinterface.h \
$$PWD/refactoringserverproxy.h \
$$PWD/referencesmessage.h \
$$PWD/set_algorithm.h \
$$PWD/stringcacheentry.h \
$$PWD/unsavedfilesupdatedmessage.h \
$$PWD/removeprojectpartsmessage.h \

View File

@@ -26,9 +26,8 @@
#include "filestatuscache.h"
#include "filesystem.h"
#include <set_algorithm.h>
#include <utils/algorithm.h>
#include <utils/set_algorithm.h>
#include <QDateTime>
#include <QFileInfo>
@@ -59,7 +58,7 @@ void FileStatusCache::update(FilePathIds filePathIds)
m_cacheEntries.end(),
filePathIds.begin(),
filePathIds.end(),
make_iterator([&](auto &entry) {
Utils::make_iterator([&](auto &entry) {
entry.lastModified = m_fileSystem.lastModified(entry.filePathId);
}));
}
@@ -73,7 +72,7 @@ FilePathIds FileStatusCache::modified(FilePathIds filePathIds) const
m_cacheEntries.end(),
filePathIds.begin(),
filePathIds.end(),
make_iterator([&](auto &entry) {
Utils::make_iterator([&](auto &entry) {
auto newLastModified = m_fileSystem.lastModified(entry.filePathId);
if (newLastModified > entry.lastModified) {
modifiedFilePathIds.push_back(entry.filePathId);
@@ -88,7 +87,7 @@ FilePathIds FileStatusCache::modified(FilePathIds filePathIds) const
filePathIds.end(),
m_cacheEntries.begin(),
m_cacheEntries.end(),
make_iterator([&](FilePathId newFilePathId) {
Utils::make_iterator([&](FilePathId newFilePathId) {
newEntries.emplace_back(newFilePathId,
m_fileSystem.lastModified(newFilePathId));
modifiedFilePathIds.push_back(newFilePathId);

View File

@@ -27,7 +27,8 @@
#include "filesysteminterface.h"
#include "modifiedtimecheckerinterface.h"
#include "set_algorithm.h"
#include <utils/set_algorithm.h>
#include <algorithm>
#include <iterator>
@@ -60,7 +61,7 @@ public:
m_currentSourceTimeStamps.end(),
filePathIds.begin(),
filePathIds.end(),
make_iterator([&](SourceTimeStamp &sourceTimeStamp) {
Utils::make_iterator([&](SourceTimeStamp &sourceTimeStamp) {
sourceTimeStamp.timeStamp = m_fileSystem.lastModified(
sourceTimeStamp.sourceId);
}));
@@ -69,7 +70,7 @@ public:
private:
bool compareEntries(const SourceEntries &sourceEntries) const
{
return !set_intersection_compare(
return !Utils::set_intersection_compare(
m_currentSourceTimeStamps.begin(),
m_currentSourceTimeStamps.end(),
sourceEntries.begin(),
@@ -99,12 +100,14 @@ private:
sourceEntries.end(),
m_currentSourceTimeStamps.begin(),
m_currentSourceTimeStamps.end(),
make_iterator([&](const SourceEntry &sourceEntry) {
Utils::make_iterator([&](const SourceEntry &sourceEntry) {
newTimeStamps.emplace_back(sourceEntry.sourceId,
m_fileSystem.lastModified(
sourceEntry.sourceId));
}),
[](auto first, auto second) { return first.sourceId < second.sourceId; });
[](auto first, auto second) {
return first.sourceId < second.sourceId;
});
return newTimeStamps;
}

View File

@@ -25,13 +25,13 @@
#pragma once
#include "set_algorithm.h"
#include "stringcachealgorithms.h"
#include "stringcacheentry.h"
#include "stringcachefwd.h"
#include <utils/algorithm.h>
#include <utils/optional.h>
#include <utils/set_algorithm.h>
#include <utils/smallstringfwd.h>
#include <QReadWriteLock>
@@ -197,7 +197,7 @@ public:
strings.end(),
m_strings.begin(),
m_strings.end(),
make_iterator([&](StringViewType newString) {
Utils::make_iterator([&](StringViewType newString) {
IndexType index = storageFunction(newString);
newCacheEntries.emplace_back(newString, index);
}),

View File

@@ -130,6 +130,7 @@ add_qtc_library(Utils
savedaction.cpp savedaction.h
savefile.cpp savefile.h
scopedswap.h
set_algorithm.h
settingsaccessor.cpp settingsaccessor.h
settingsselector.cpp settingsselector.h
settingsutils.h

View File

@@ -27,7 +27,7 @@
#include <algorithm>
namespace ClangBackEnd {
namespace Utils {
template<class Callable>
class function_output_iterator
@@ -116,4 +116,5 @@ Value mismatch_collect(InputIt1 first1,
return value;
}
} // namespace ClangBackEnd
} // namespace Utils

View File

@@ -298,7 +298,8 @@ HEADERS += \
$$PWD/porting.h \
$$PWD/aspects.h \
$$PWD/layoutbuilder.h \
$$PWD/variablechooser.h
$$PWD/variablechooser.h \
$$PWD/set_algorithm.h
FORMS += $$PWD/filewizardpage.ui \
$$PWD/projectintropage.ui \

View File

@@ -236,7 +236,8 @@ Project {
"savedaction.h",
"savefile.cpp",
"savefile.h",
"scopedswap.h",
"scopedswap.h"
"set_algorithm.h",
"settingsaccessor.cpp",
"settingsaccessor.h",
"settingsselector.cpp",

View File

@@ -31,9 +31,10 @@
#include <filepathcachinginterface.h>
#include <generatedfilesinterface.h>
#include <projectpartcontainer.h>
#include <set_algorithm.h>
#include <usedmacrofilter.h>
#include <utils/set_algorithm.h>
#include <algorithm>
#include <utils/algorithm.h>
@@ -163,7 +164,7 @@ ProjectPartsManagerInterface::UpToDataProjectParts ProjectPartsManager::checkDep
newSources.end(),
oldSources.begin(),
oldSources.end(),
make_iterator([&](SourceEntry entry) {
Utils::make_iterator([&](SourceEntry entry) {
change = changedSourceType(entry, change);
}),
[](SourceEntry first, SourceEntry second) {
@@ -185,7 +186,7 @@ ProjectPartsManagerInterface::UpToDataProjectParts ProjectPartsManager::checkDep
}
if (change == Change::No) {
Change change = mismatch_collect(
Change change = Utils::mismatch_collect(
newSources.begin(),
newSources.end(),
oldSources.begin(),