mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
Delegate parts of CSequence to a non-template implementation
To reduce build time.
This commit is contained in:
31
src/blackmisc/sequence.cpp
Normal file
31
src/blackmisc/sequence.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 2021
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#include "blackmisc/sequence.h"
|
||||
#include <numeric>
|
||||
|
||||
namespace BlackMisc::Private
|
||||
{
|
||||
QVector<int> findIndices(int size, const std::function<bool(int)> &predicate)
|
||||
{
|
||||
QVector<int> result(size);
|
||||
std::iota(result.begin(), result.end(), 0);
|
||||
result.erase(std::remove_if(result.begin(), result.end(), std::not_fn(predicate)), result.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
QVector<int> sortIndices(int size, const std::function<bool(int, int)> &cmp)
|
||||
{
|
||||
QVector<int> result(size);
|
||||
std::iota(result.begin(), result.end(), 0);
|
||||
std::sort(result.begin(), result.end(), cmp);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user