mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 05:45:35 +08:00
Issue #77 Remove pointless function
This commit is contained in:
@@ -1,46 +0,0 @@
|
|||||||
/* Copyright (C) 2016
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "blackmisc/dictionary.h"
|
|
||||||
|
|
||||||
uint BlackMisc::calculateHash(const QList<uint> &values, const char *className)
|
|
||||||
{
|
|
||||||
// http://stackoverflow.com/questions/113511/hash-code-implementation/113600#113600
|
|
||||||
if (values.isEmpty()) return 0;
|
|
||||||
uint hash = values.first();
|
|
||||||
for (int i = 1; i < values.size(); i++)
|
|
||||||
{
|
|
||||||
hash = 37 * hash + values.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// same values, but different class?
|
|
||||||
if (className)
|
|
||||||
{
|
|
||||||
hash = 37 * hash + qHash(QString(className));
|
|
||||||
}
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint BlackMisc::calculateHash(const QList<int> &values, const char *className)
|
|
||||||
{
|
|
||||||
QList<uint> list;
|
|
||||||
uint s = 0;
|
|
||||||
foreach(int i, values)
|
|
||||||
{
|
|
||||||
if (i >= 0)
|
|
||||||
{
|
|
||||||
list.append(static_cast<uint>(i));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
list.append(static_cast<uint>(i));
|
|
||||||
list.append(s++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return calculateHash(list, className);
|
|
||||||
}
|
|
||||||
@@ -537,17 +537,6 @@ namespace BlackMisc
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* Calculate a single hash value based on a list of individual hash values.
|
|
||||||
* \param values
|
|
||||||
* \param className Will be hashed and used as an additional value in the list.
|
|
||||||
*/
|
|
||||||
//! @{
|
|
||||||
BLACKMISC_EXPORT uint calculateHash(const QList<uint> &values, const char *className);
|
|
||||||
|
|
||||||
BLACKMISC_EXPORT uint calculateHash(const QList<int> &values, const char *className);
|
|
||||||
//! @}
|
|
||||||
|
|
||||||
} // namespace BlackMisc
|
} // namespace BlackMisc
|
||||||
|
|
||||||
#endif // BLACKMISC_DICTIONARY_H
|
#endif // BLACKMISC_DICTIONARY_H
|
||||||
|
|||||||
@@ -424,11 +424,9 @@ namespace BlackMisc
|
|||||||
template <class MU, class PQ>
|
template <class MU, class PQ>
|
||||||
uint CPhysicalQuantity<MU, PQ>::getValueHash() const
|
uint CPhysicalQuantity<MU, PQ>::getValueHash() const
|
||||||
{
|
{
|
||||||
QList<uint> hashs;
|
|
||||||
// there is no double qHash
|
// there is no double qHash
|
||||||
// also unit and rounding has to be considered
|
// also unit and rounding has to be considered
|
||||||
hashs << qHash(this->valueRoundedWithUnit(MU::defaultUnit()));
|
return qHash(this->valueRoundedWithUnit(MU::defaultUnit()));
|
||||||
return calculateHash(hashs, "PQ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MU, class PQ>
|
template <class MU, class PQ>
|
||||||
|
|||||||
@@ -149,10 +149,7 @@ namespace BlackMisc
|
|||||||
uint CPropertyIndexVariantMap::getValueHash() const
|
uint CPropertyIndexVariantMap::getValueHash() const
|
||||||
{
|
{
|
||||||
// there is no hash for map, so I use this workaround here
|
// there is no hash for map, so I use this workaround here
|
||||||
const QString s = this->toQString(false);
|
return qHash(this->toQString(false));
|
||||||
QList<uint> h;
|
|
||||||
h << qHash(s);
|
|
||||||
return BlackMisc::calculateHash(h, "CPropertyIndexVariantMap");
|
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user