Python dictionary - binary search for a key?

后端 未结 5 1318
长发绾君心
长发绾君心 2021-02-05 19:16

I want to write a container class that acts like a dictionary (actually derives from a dict), The keys for this structure will be dates.

When a key (i.e. date) is used t

5条回答
  •  清酒与你
    2021-02-05 19:51

    Why not just maintain a sorted list from dict.keys() and search that? If you're subclassing dict you may even devise an opportunity to do a binary insert on that list when values are added.

提交回复
热议问题