mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-04 16:14:05 +00:00
Use std::sort in suitable places
This commit is contained in:
parent
73ec1b5950
commit
278c143a05
|
@ -1418,7 +1418,7 @@ void BtreeIndex::getHeadwordsFromOffsets( QList<uint32_t> & offsets,
|
||||||
uint32_t nextLeaf = 0;
|
uint32_t nextLeaf = 0;
|
||||||
uint32_t leafEntries;
|
uint32_t leafEntries;
|
||||||
|
|
||||||
qSort( offsets );
|
std::sort( offsets.begin(), offsets.end() );
|
||||||
|
|
||||||
Mutex::Lock _( *idxFileMutex );
|
Mutex::Lock _( *idxFileMutex );
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
@ -195,7 +196,7 @@ public:
|
||||||
// Default - simple sorting in increase order
|
// Default - simple sorting in increase order
|
||||||
virtual void sortArticlesOffsetsForFTS( QVector< uint32_t > & offsets,
|
virtual void sortArticlesOffsetsForFTS( QVector< uint32_t > & offsets,
|
||||||
QAtomicInt & isCancelled )
|
QAtomicInt & isCancelled )
|
||||||
{ Q_UNUSED( isCancelled ); qSort( offsets ); }
|
{ Q_UNUSED( isCancelled ); std::sort( offsets.begin(), offsets.end() ); }
|
||||||
|
|
||||||
/// Called before each matching operation to ensure that any child init
|
/// Called before each matching operation to ensure that any child init
|
||||||
/// has completed. Mainly used for deferred init. The default implementation
|
/// has completed. Mainly used for deferred init. The default implementation
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtAlgorithms>
|
#include <QtAlgorithms>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "favoritespanewidget.hh"
|
#include "favoritespanewidget.hh"
|
||||||
#include "gddebug.hh"
|
#include "gddebug.hh"
|
||||||
|
@ -906,7 +907,7 @@ void FavoritesModel::removeItemsForIndexes( const QModelIndexList & idxList )
|
||||||
for( int i = lowestLevel; i >= 0; i-- )
|
for( int i = lowestLevel; i >= 0; i-- )
|
||||||
{
|
{
|
||||||
QModelIndexList idxSublist = itemsToDelete[ i ];
|
QModelIndexList idxSublist = itemsToDelete[ i ];
|
||||||
qSort( idxSublist.begin(), idxSublist.end(), qGreater< QModelIndex >() );
|
std::sort( idxSublist.begin(), idxSublist.end(), qGreater< QModelIndex >() );
|
||||||
|
|
||||||
it = idxSublist.begin();
|
it = idxSublist.begin();
|
||||||
for( ; it != idxSublist.end(); ++it )
|
for( ; it != idxSublist.end(); ++it )
|
||||||
|
|
|
@ -665,7 +665,7 @@ Q_UNUSED( parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
headwords.append( temp );
|
headwords.append( temp );
|
||||||
qSort( headwords );
|
std::sort( headwords.begin(), headwords.end() );
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
emit contentChanged();
|
emit contentChanged();
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#include "historypanewidget.hh"
|
#include "historypanewidget.hh"
|
||||||
|
|
||||||
|
@ -137,7 +139,7 @@ void HistoryPaneWidget::deleteSelectedItems()
|
||||||
|
|
||||||
// Need to sort indexes in the decreasing order so that
|
// Need to sort indexes in the decreasing order so that
|
||||||
// the first deletions won't affect the indexes for subsequent deletions.
|
// the first deletions won't affect the indexes for subsequent deletions.
|
||||||
qSort( idxsToDelete.begin(), idxsToDelete.end(), qGreater<int>() );
|
std::sort( idxsToDelete.begin(), idxsToDelete.end(), std::greater<int>() );
|
||||||
|
|
||||||
QListIterator<int> idxs( idxsToDelete );
|
QListIterator<int> idxs( idxsToDelete );
|
||||||
while ( idxs.hasNext() )
|
while ( idxs.hasNext() )
|
||||||
|
|
3
slob.cc
3
slob.cc
|
@ -43,6 +43,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace Slob {
|
namespace Slob {
|
||||||
|
|
||||||
|
@ -414,7 +415,7 @@ const SlobFile::RefOffsetsVector & SlobFile::getSortedRefOffsets()
|
||||||
refsOffsetVector.append( RefEntryOffsetItem( base + qFromBigEndian( tmp ), i ) );
|
refsOffsetVector.append( RefEntryOffsetItem( base + qFromBigEndian( tmp ), i ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
qSort( refsOffsetVector );
|
std::sort( refsOffsetVector.begin(), refsOffsetVector.end() );
|
||||||
return refsOffsetVector;
|
return refsOffsetVector;
|
||||||
}
|
}
|
||||||
QString error = fileName + ": " + file.errorString();
|
QString error = fileName + ": " + file.errorString();
|
||||||
|
|
7
zim.cc
7
zim.cc
|
@ -42,6 +42,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace Zim {
|
namespace Zim {
|
||||||
|
|
||||||
|
@ -290,7 +291,7 @@ bool ZimFile::open()
|
||||||
for( quint32 i = 0; i < zimHeader.clusterCount; i++ )
|
for( quint32 i = 0; i < zimHeader.clusterCount; i++ )
|
||||||
clusterOffsets[ i ] = QPair< quint64, quint32 >( offs.at( i ), i );
|
clusterOffsets[ i ] = QPair< quint64, quint32 >( offs.at( i ), i );
|
||||||
|
|
||||||
qSort( clusterOffsets );
|
std::sort( clusterOffsets.begin(), clusterOffsets.end() );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1027,7 +1028,7 @@ void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
|
||||||
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
|
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
|
||||||
throw exUserAbort();
|
throw exUserAbort();
|
||||||
|
|
||||||
qSort( offsetsWithClusters );
|
std::sort( offsetsWithClusters.begin(), offsetsWithClusters.end() );
|
||||||
|
|
||||||
QVector< uint32_t > offsets;
|
QVector< uint32_t > offsets;
|
||||||
offsets.resize( offsetsWithClusters.size() );
|
offsets.resize( offsetsWithClusters.size() );
|
||||||
|
@ -1134,7 +1135,7 @@ void ZimDictionary::sortArticlesOffsetsForFTS( QVector< uint32_t > & offsets,
|
||||||
offsetsWithClusters.append( QPair< uint32_t, quint32 >( getArticleCluster( df, *it ), *it ) );
|
offsetsWithClusters.append( QPair< uint32_t, quint32 >( getArticleCluster( df, *it ), *it ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
qSort( offsetsWithClusters );
|
std::sort( offsetsWithClusters.begin(), offsetsWithClusters.end() );
|
||||||
|
|
||||||
for( int i = 0; i < offsetsWithClusters.size(); i++ )
|
for( int i = 0; i < offsetsWithClusters.size(); i++ )
|
||||||
offsets[ i ] = offsetsWithClusters.at( i ).second;
|
offsets[ i ] = offsetsWithClusters.at( i ).second;
|
||||||
|
|
Loading…
Reference in a new issue