Iota for less loops.

This commit is contained in:
2024-04-24 21:22:25 -04:00
parent 17c8c9aed4
commit 93cd0f7324
+4 -4
View File
@@ -23,6 +23,7 @@
#include <memory> #include <memory>
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <numeric>
#include "../gamestr.h" #include "../gamestr.h"
#include "../starmap.h" #include "../starmap.h"
@@ -50,12 +51,11 @@ compStarName (const int index1, const int index2)
static void static void
SortStarsOnName (STAR_SEARCH_STATE *pSS) SortStarsOnName (STAR_SEARCH_STATE *pSS)
{ {
std::cerr << "ADAM C++: Star sorting!" << std::endl; //std::cerr << "ADAM C++: Star sorting!" << std::endl;
int i;
int *sorted = pSS->SortedStars; int *sorted = pSS->SortedStars;
for (i = 0; i < GetStarCount(); i++) std::iota( sorted, sorted + GetStarCount(), 0 );
sorted[i] = i;
std::sort( sorted, sorted + GetStarCount(), compStarName ); std::sort( sorted, sorted + GetStarCount(), compStarName );
} }