Use std::sort instead of bubble_sort

This commit is contained in:
Jupeyy 2020-10-08 07:28:53 +02:00
parent 6376890fc1
commit 52911e4302
7 changed files with 14 additions and 13 deletions

View file

@ -4,6 +4,7 @@
#define BASE_TL_ALGORITHM_H
#include "base/tl/range.h"
#include <algorithm>
#include <functional>
/*
@ -108,7 +109,7 @@ void sort_quick(R range)
template<class R>
void sort(R range)
{
sort_bubble(range);
std::sort(&range.front(), &range.back() + 1);
}
template<class R>

View file

@ -15,7 +15,7 @@ public:
char m_aCountryCodeString[8];
IGraphics::CTextureHandle m_Texture;
bool operator<(const CCountryFlag &Other) { return str_comp(m_aCountryCodeString, Other.m_aCountryCodeString) < 0; }
bool operator<(const CCountryFlag &Other) const { return str_comp(m_aCountryCodeString, Other.m_aCountryCodeString) < 0; }
};
void OnInit();

View file

@ -316,7 +316,7 @@ protected:
const CFriendInfo *m_pFriendInfo;
int m_NumFound;
bool operator<(const CFriendItem &Other)
bool operator<(const CFriendItem &Other) const
{
if(m_NumFound && !Other.m_NumFound)
return true;
@ -473,7 +473,7 @@ public:
CGhostItem() :
m_Slot(-1), m_Own(false) { m_aFilename[0] = 0; }
bool operator<(const CGhostItem &Other) { return m_Time < Other.m_Time; }
bool operator<(const CGhostItem &Other) const { return m_Time < Other.m_Time; }
bool Active() const { return m_Slot != -1; }
bool HasFile() const { return m_aFilename[0]; }

View file

@ -1302,7 +1302,7 @@ public:
string m_FileName;
int m_CountryCode;
bool operator<(const CLanguage &Other) { return m_Name < Other.m_Name; }
bool operator<(const CLanguage &Other) const { return m_Name < Other.m_Name; }
};
void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array<CLanguage> *pLanguages)

View file

@ -20,10 +20,10 @@ public:
char m_aName[24];
ColorRGBA m_BloodColor;
bool operator<(const CSkin &Other) { return str_comp(m_aName, Other.m_aName) < 0; }
bool operator<(const CSkin &Other) const { return str_comp(m_aName, Other.m_aName) < 0; }
bool operator<(const char *pOther) { return str_comp(m_aName, pOther) < 0; }
bool operator==(const char *pOther) { return !str_comp(m_aName, pOther); }
bool operator<(const char *pOther) const { return str_comp(m_aName, pOther) < 0; }
bool operator==(const char *pOther) const { return !str_comp(m_aName, pOther); }
};
struct CDownloadSkin
@ -32,9 +32,9 @@ public:
char m_aPath[MAX_PATH_LENGTH];
char m_aName[24];
bool operator<(const CDownloadSkin &Other) { return str_comp(m_aName, Other.m_aName) < 0; }
bool operator<(const char *pOther) { return str_comp(m_aName, pOther) < 0; }
bool operator==(const char *pOther) { return !str_comp(m_aName, pOther); }
bool operator<(const CDownloadSkin &Other) const { return str_comp(m_aName, Other.m_aName) < 0; }
bool operator<(const char *pOther) const { return str_comp(m_aName, pOther) < 0; }
bool operator==(const char *pOther) const { return !str_comp(m_aName, pOther); }
};
void OnInit();

View file

@ -881,7 +881,7 @@ public:
int m_StorageType;
bool m_IsVisible;
bool operator<(const CFilelistItem &Other) { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false : m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false : str_comp_nocase(m_aFilename, Other.m_aFilename) < 0; }
bool operator<(const CFilelistItem &Other) const { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false : m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false : str_comp_nocase(m_aFilename, Other.m_aFilename) < 0; }
};
sorted_array<CFilelistItem> m_FileList;
int m_FilesStartAt;

View file

@ -347,7 +347,7 @@ struct CEnvPoint
int m_Curvetype;
int m_aValues[4]; // 1-4 depending on envelope (22.10 fixed point)
bool operator<(const CEnvPoint &Other) { return m_Time < Other.m_Time; }
bool operator<(const CEnvPoint &Other) const { return m_Time < Other.m_Time; }
};
struct CMapItemEnvelope_v1