Python 2.6 TreeMap/SortedDictionary?

只愿长相守 提交于 2019-12-18 04:32:57

问题


Is there a built-in sorted dictionary implementation in Python 2.6, or are hashtables the only kind?

Clarifications:

  • I'm asking about sorted dictionarys, not ordered dictionaries!

回答1:


I think the answer here is no.

There is a Treemap but it isn't in the python standard library.

http://pypi.python.org/pypi/treemap/

I think to those who don't like my answer, may think it's wrong due to a recent update. Please note this is for Python 2.6, not 2.7 or Python 3

Please add the correct answer if you still think it's wrong, or unhelpful, or at least give a reason why you think it's a bad answer.




回答2:


Built-in no, as a third party package you can check blist , here is the doc for sorteddict.




回答3:


If by build-in you mean provided with a standard python install, the answer is no.

If you mean at the same level of implementation as Python's build-in dict then have a look at my C implementation of sorteddict and ordereddict: http://anthon.home.xs4all.nl/Python/ordereddict/



来源:https://stackoverflow.com/questions/6886294/python-2-6-treemap-sorteddictionary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!