Rewrote insertionSort to only require operator< (no >),
and removed the unnecessary operators.
This commit is contained in:
@@ -297,33 +297,6 @@ public:
|
||||
return true;
|
||||
} // operator<
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Compares two addons according to the sort order currently defined.
|
||||
* Comparison is done for sorting in descending order.
|
||||
* \param a The addon to compare this addon to.
|
||||
*/
|
||||
bool operator>(const Addon &a) const
|
||||
{
|
||||
switch(m_sort_order)
|
||||
{
|
||||
case SO_DEFAULT:
|
||||
if(testStatus(AS_FEATURED) &&
|
||||
!a.testStatus(AS_FEATURED)) return true;
|
||||
if(!testStatus(AS_FEATURED) &&
|
||||
a.testStatus(AS_FEATURED)) return false;
|
||||
// Otherwise fall through to name comparison!
|
||||
case SO_NAME:
|
||||
// m_id is the lower case name
|
||||
return m_id > a.m_id;
|
||||
break;
|
||||
case SO_DATE:
|
||||
return m_date < a.m_date;
|
||||
break;
|
||||
} // switch
|
||||
// Fix compiler warning.
|
||||
return true;
|
||||
} // operator>
|
||||
|
||||
}; // Addon
|
||||
|
||||
|
||||
|
||||
@@ -266,11 +266,4 @@ bool PlayerProfile::operator<(const PlayerProfile &other)
|
||||
} // operator<
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** \brief Needed for toggling sort order **/
|
||||
bool PlayerProfile::operator>(const PlayerProfile &other)
|
||||
{
|
||||
return m_use_frequency > other.m_use_frequency;
|
||||
} // operator>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -116,7 +116,6 @@ public:
|
||||
void initRemainingData();
|
||||
void incrementUseFrequency();
|
||||
bool operator<(const PlayerProfile &other);
|
||||
bool operator>(const PlayerProfile &other);
|
||||
void raceFinished();
|
||||
void saveSession(int user_id, const std::string &token);
|
||||
void clearSession();
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Online{
|
||||
break;
|
||||
case SO_NAME:
|
||||
// m_id is the lower case name
|
||||
return m_name < server.getName();
|
||||
return m_lower_case_name < server.m_lower_case_name;
|
||||
break;
|
||||
case SO_PLAYERS:
|
||||
return m_current_players < server.getCurrentPlayers();
|
||||
@@ -109,28 +109,6 @@ namespace Online{
|
||||
return true;
|
||||
} // operator<
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Compares two addons according to the sort order currently defined.
|
||||
* Comparison is done for sorting in descending order.
|
||||
* \param a The addon to compare this addon to.
|
||||
*/
|
||||
bool operator>(const Server &server) const
|
||||
{
|
||||
switch(m_sort_order)
|
||||
{
|
||||
case SO_SCORE:
|
||||
return m_satisfaction_score > server.getScore();
|
||||
break;
|
||||
case SO_NAME:
|
||||
return m_lower_case_name > server.getLowerCaseName();
|
||||
break;
|
||||
case SO_PLAYERS:
|
||||
return m_current_players > server.getCurrentPlayers();
|
||||
break;
|
||||
} // switch
|
||||
return true;
|
||||
} // operator>
|
||||
|
||||
}; // Server
|
||||
} // namespace Online
|
||||
|
||||
|
||||
@@ -555,13 +555,6 @@ namespace computeGPRanksData
|
||||
(m_score == a.m_score && m_race_time < a.m_race_time) );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
bool operator>(const SortData &a)
|
||||
{
|
||||
return ( (m_score < a.m_score) ||
|
||||
(m_score == a.m_score && m_race_time > a.m_race_time) );
|
||||
}
|
||||
|
||||
}; // SortData
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -170,19 +170,6 @@ bool Track::operator<(const Track &other) const
|
||||
return other_is_locked;
|
||||
} // operator<
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Track::operator>(const Track &other) const
|
||||
{
|
||||
PlayerProfile *p = PlayerManager::getCurrentPlayer();
|
||||
bool this_is_locked = p->isLocked(getIdent());
|
||||
bool other_is_locked = p->isLocked(other.getIdent());
|
||||
if(this_is_locked == other_is_locked)
|
||||
{
|
||||
return !(getSortName() < other.getSortName());
|
||||
}
|
||||
else
|
||||
return this_is_locked;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns the name of the track, which is e.g. displayed on the screen.
|
||||
\note this is the LTR name, invoke fribidi as needed. */
|
||||
|
||||
@@ -616,7 +616,6 @@ public:
|
||||
float getDisplacementSpeed() const { return m_displacement_speed; }
|
||||
float getCausticsSpeed() const { return m_caustics_speed; }
|
||||
bool operator<(const Track &other) const;
|
||||
bool operator>(const Track &other) const;
|
||||
}; // class Track
|
||||
|
||||
#endif
|
||||
|
||||
@@ -277,7 +277,7 @@ public:
|
||||
{
|
||||
for(int j=(int)start; j<(int)m_contents_vector.size()-1; j++)
|
||||
{
|
||||
if(*(m_contents_vector[j])>*(m_contents_vector[j+1])) continue;
|
||||
if(*(m_contents_vector[j+1])<*(m_contents_vector[j])) continue;
|
||||
// Now search the proper place for m_contents_vector[j+1]
|
||||
// in the sorted section contentsVectot[start:j]
|
||||
TYPE* t=m_contents_vector[j+1];
|
||||
@@ -286,7 +286,7 @@ public:
|
||||
{
|
||||
m_contents_vector[i] = m_contents_vector[i-1];
|
||||
i--;
|
||||
} while (i>start && *t>*(m_contents_vector[i-1]));
|
||||
} while (i>start && *(m_contents_vector[i-1]) <*t);
|
||||
m_contents_vector[i]=t;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user