summaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-05-07 18:31:29 +0000
committersmatz <smatz@openttd.org>2008-05-07 18:31:29 +0000
commit3445b8054c81e12dc0d0078135a73eafe10a309f (patch)
treeea776ead1303bca953cbbccb0a0e78e08c7eaa45 /src/engine.cpp
parent220bc49731e8f32cf92f31defab1bd5e313f7dc7 (diff)
downloadopenttd-3445b8054c81e12dc0d0078135a73eafe10a309f.tar.xz
(svn r12995) -Codechange: use std::vector for EngineList instead of C/C++ wrapper for CBlobT
Diffstat (limited to 'src/engine.cpp')
-rw-r--r--src/engine.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 3d9df73f3..c28b096cb 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -114,6 +114,28 @@ Engine::~Engine()
free(this->name);
}
+/** Sort all items using qsort() and given 'CompareItems' function
+ * @param el list to be sorted
+ * @param compare function for evaluation of the quicksort
+ */
+void EngList_Sort(EngineList *el, EngList_SortTypeFunction compare)
+{
+ qsort(&((*el)[0]), el->size(), sizeof(EngineID), compare);
+}
+
+/** Sort selected range of items (on indices @ <begin, begin+num_items-1>)
+ * @param el list to be sorted
+ * @param compare function for evaluation of the quicksort
+ * @param begin start of sorting
+ * @param num_items count of items to be sorted
+ */
+void EngList_SortPartial(EngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items)
+{
+ assert(begin <= (uint)el->size());
+ assert(begin + num_items <= (uint)el->size());
+ qsort(&((*el)[begin]), num_items, sizeof(EngineID), compare);
+}
+
void SetupEngines()
{
_Engine_pool.CleanPool();