Skip to content

Commit ce541cb

Browse files
committed
Use std::size_t
1 parent c360e37 commit ce541cb

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/analysis/processing/qgsalgorithmkmeansclustering.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ QVariantMap QgsKMeansClusteringAlgorithm::processAlgorithm( const QVariantMap &p
182182

183183
void QgsKMeansClusteringAlgorithm::initClusters( std::vector<Feature> &points, std::vector<QgsPointXY> &centers, const int k, QgsProcessingFeedback *feedback )
184184
{
185-
ulong n = points.size();
185+
std::size_t n = points.size();
186186
if ( n == 0 )
187187
return;
188188

@@ -195,12 +195,12 @@ void QgsKMeansClusteringAlgorithm::initClusters( std::vector<Feature> &points, s
195195

196196
long duplicateCount = 1;
197197
// initially scan for two most distance points from each other, p1 and p2
198-
ulong p1 = 0;
199-
ulong p2 = 0;
198+
std::size_t p1 = 0;
199+
std::size_t p2 = 0;
200200
double distanceP1 = 0;
201201
double distanceP2 = 0;
202202
double maxDistance = -1;
203-
for ( ulong i = 1; i < n; i++ )
203+
for ( std::size_t i = 1; i < n; i++ )
204204
{
205205
distanceP1 = points[i].point.sqrDist( points[p1].point );
206206
distanceP2 = points[i].point.sqrDist( points[p2].point );
@@ -238,7 +238,7 @@ void QgsKMeansClusteringAlgorithm::initClusters( std::vector<Feature> &points, s
238238
std::vector< double > distances( n );
239239

240240
// initialize array with distance to first object
241-
for ( ulong j = 0; j < n; j++ )
241+
for ( std::size_t j = 0; j < n; j++ )
242242
{
243243
distances[j] = points[j].point.sqrDist( centers[0] );
244244
}
@@ -248,11 +248,11 @@ void QgsKMeansClusteringAlgorithm::initClusters( std::vector<Feature> &points, s
248248
// loop i on clusters, skip 0 and 1 as found already
249249
for ( int i = 2; i < k; i++ )
250250
{
251-
ulong candidateCenter = 0;
251+
std::size_t candidateCenter = 0;
252252
double maxDistance = std::numeric_limits<double>::lowest();
253253

254254
// loop j on points
255-
for ( ulong j = 0; j < n; j++ )
255+
for ( std::size_t j = 0; j < n; j++ )
256256
{
257257
// accepted clusters are already marked with distance = -1
258258
if ( distances[j] < 0 )
@@ -312,8 +312,8 @@ void QgsKMeansClusteringAlgorithm::calculateKMeans( std::vector<QgsKMeansCluster
312312
void QgsKMeansClusteringAlgorithm::findNearest( std::vector<QgsKMeansClusteringAlgorithm::Feature> &points, const std::vector<QgsPointXY> &centers, const int k, bool &changed )
313313
{
314314
changed = false;
315-
ulong n = points.size();
316-
for ( ulong i = 0; i < n; i++ )
315+
std::size_t n = points.size();
316+
for ( std::size_t i = 0; i < n; i++ )
317317
{
318318
Feature &point = points[i];
319319

0 commit comments

Comments
 (0)