Sorted hash table (map, dictionary) data structure design

前端 未结 6 962
猫巷女王i
猫巷女王i 2020-12-29 00:14

Here\'s a description of the data structure:

It operates like a regular map with get, put, and remove methods, but has a

6条回答
  •  佛祖请我去吃肉
    2020-12-29 00:25

    Why exactly do you need a sort() function ?
    What do you perhaps want and need is a Red-Black Tree.

    http://en.wikipedia.org/wiki/Red-black_tree

    These trees are automatically sorting your input by a comparator you give. They are complex, but have excellent O(n) characteristics. Couple your tree entries as key with a hash map as dictionary and you get your datastructure.

    In Java it is implemented as TreeMap as instance of SortedMap.

提交回复
热议问题