Originally posted by coder
View Post
First, associative arrays like hashmap, btreemap, or other tree based map always have a much higher overhead than plain array.
Sorting the array can archive the same performance as btreemap or other tree based map since they are O(log(n)), the advantage of associative arrays is that you can add/remove new items at runtime quickly, but it doesn't need the functionality here.
Second, it's hard to construct an associative array at compile time. For hashmap, you might be able to workaround this since it can be backed by an array, but tree based map needs to allocate a lot of small nodes and that would need users to allocate an array of small nodes at compile time.
A small sorted array, is easiest to archive here.
Comment