refs #501, compareByPropertyIndex (performance for sort)

This commit is contained in:
Klaus Basan
2015-10-26 19:13:43 +01:00
committed by Mathew Sutcliffe
parent 1e57ce7ecb
commit 0c94922bd6
55 changed files with 692 additions and 131 deletions

View File

@@ -36,12 +36,11 @@ namespace BlackMisc
CPropertyIndex CPropertyIndex::copyFrontRemoved() const
{
Q_ASSERT(!this->isEmpty());
Q_ASSERT_X(!this->isEmpty(), Q_FUNC_INFO, "Empty index");
if (this->isEmpty()) { return CPropertyIndex(); }
QList<int> l = this->indexList();
l.removeAt(0);
CPropertyIndex pi(l);
return pi;
int p = this->m_indexString.indexOf(';');
if (p < 0) { return CPropertyIndex(); }
return CPropertyIndex(this->m_indexString.mid(p + 1));
}
bool CPropertyIndex::isNested() const
@@ -102,7 +101,7 @@ namespace BlackMisc
QList<int> list;
if (this->m_indexString.isEmpty()) { return list; }
QStringList indexes = this->m_indexString.split(';');
foreach(QString index, indexes)
for (const QString &index : indexes)
{
if (index.isEmpty()) { continue; }
bool ok;
@@ -126,4 +125,22 @@ namespace BlackMisc
return this->indexList().contains(index);
}
int CPropertyIndex::frontToInt() const
{
Q_ASSERT_X(!this->isEmpty(), Q_FUNC_INFO, "No index");
int f = -1;
bool ok;
int p = this->m_indexString.indexOf(';');
if (p < 0)
{
f = this->m_indexString.toInt(&ok);
}
else
{
f = this->m_indexString.left(p).toInt(&ok);
}
Q_ASSERT_X(ok && f >= 0, Q_FUNC_INFO, "Invalid index");
return f;
}
} // namespace