mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #501, compareByPropertyIndex (performance for sort)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
1e57ce7ecb
commit
0c94922bd6
42
src/blackmisc/comparefunctions.cpp
Normal file
42
src/blackmisc/comparefunctions.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 and at http://www.swift-project.org/license.html. 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.
|
||||
*/
|
||||
|
||||
#include "comparefunctions.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Compare
|
||||
{
|
||||
int compare(bool a, bool b)
|
||||
{
|
||||
if ((a && b) || (!a && !b)) return 0;
|
||||
if (a && !b) return 10;
|
||||
return -10;
|
||||
}
|
||||
|
||||
int compare(int a, int b)
|
||||
{
|
||||
if (a == b) return 0;
|
||||
return a < b ? -10 : 10;
|
||||
}
|
||||
|
||||
int compare(qint64 a, qint64 b)
|
||||
{
|
||||
if (a == b) return 0;
|
||||
return a < b ? -10 : 10;
|
||||
}
|
||||
|
||||
int compare(double a, double b)
|
||||
{
|
||||
if (a == b) return 0;
|
||||
return a < b ? -10 : 10;
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
Reference in New Issue
Block a user