From fbe31ada800b3417d10a24f6c0481d3cb6b161e4 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Thu, 9 Feb 2023 13:16:30 +0800 Subject: Use stable sort in generation of lookup tables (#2638) * Add Slang::List::stableSort * Use stable sort in generation of lookup tables * Disable newline translation when writing lookup tables --- source/core/slang-list.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'source/core') diff --git a/source/core/slang-list.h b/source/core/slang-list.h index 187ff3109..ff756035c 100644 --- a/source/core/slang-list.h +++ b/source/core/slang-list.h @@ -448,13 +448,13 @@ namespace Slang return -1; } + bool contains(const T& val) const { return indexOf(val) != Index(-1); } + void sort() { sort([](const T& t1, const T& t2){return t1 < t2;}); } - bool contains(const T& val) const { return indexOf(val) != Index(-1); } - template void sort(Comparer compare) { @@ -463,6 +463,17 @@ namespace Slang std::sort(m_buffer, m_buffer + m_count, compare); } + void stableSort() + { + stableSort([](const T& t1, const T& t2){return t1 < t2;}); + } + + template + void stableSort(Comparer compare) + { + std::stable_sort(m_buffer, m_buffer + m_count, compare); + } + template void forEach(IterateFunc f) const { -- cgit v1.2.3