summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-02-09 13:16:30 +0800
committerGitHub <noreply@github.com>2023-02-09 13:16:30 +0800
commitfbe31ada800b3417d10a24f6c0481d3cb6b161e4 (patch)
tree5d1e91706ecee08bcd5bc4763f2ad836a4c17815 /source/core
parent6bbd67390e9693d6a60221a030270d5ab67edfb9 (diff)
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
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-list.h15
1 files changed, 13 insertions, 2 deletions
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<typename Comparer>
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<typename Comparer>
+ void stableSort(Comparer compare)
+ {
+ std::stable_sort(m_buffer, m_buffer + m_count, compare);
+ }
+
template <typename IterateFunc>
void forEach(IterateFunc f) const
{