diff options
Diffstat (limited to 'src/core/smallmap_type.hpp')
-rw-r--r-- | src/core/smallmap_type.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp index 681cacdff..cc2533dd0 100644 --- a/src/core/smallmap_type.hpp +++ b/src/core/smallmap_type.hpp @@ -96,6 +96,18 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> { n->first = key; return n->second; } + + FORCEINLINE void SortByKey() + { + qsort(this->Begin(), this->items, sizeof(Pair), KeySorter); + } + + static int CDECL KeySorter(const void *a, const void *b) + { + const Pair *pa = (const Pair*)a; + const Pair *pb = (const Pair*)b; + return pa->first - pb->first; + } }; #endif /* SMALLMAP_TYPE_HPP */ |