21#ifndef SCUMM_INSANE_HIGHSCORES_H
22#define SCUMM_INSANE_HIGHSCORES_H
24#include "common/util.h"
28template<
class Entry,
class Score>
29int findHighScorePosition(
const Entry *entries,
int count, Score score,
bool beforeEqual =
false) {
31 while (position < count && (entries[position].score > score ||
32 (!beforeEqual && entries[position].score == score)))
38int insertHighScoreEntry(Entry *entries,
int count,
int capacity,
int position,
const Entry &entry) {
39 assert(count >= 0 && count <= capacity && position >= 0 && position <= count);
40 if (position >= capacity)
42 for (
int i =
MIN(count, capacity - 1); i > position; --i)
43 entries[i] = entries[i - 1];
44 entries[position] = entry;
45 return MIN(count + 1, capacity);
T MIN(T a, T b)
Definition: util.h:63