Is an iteration on a F# map or set in-order traversal?

痴心易碎 提交于 2019-12-10 17:32:59

问题


AFAIK, F# Map and set are implemented as red-black trees, so I guess that an iteration on these would be in-order traversal. I did some test and the iteration results are always sorted. But I want to make it sure.

Is it in-order traversal?


回答1:


The documentation on MSDN is pretty good for figuring this out. For instance, the return value for Set.toSeq is "An ordered sequence of the elements of set." It looks like the answer to your question is yes, for both maps and sets.




回答2:


AFAIK, F# Map and set are implemented as red-black trees

AVL trees.

Is it in-order traversal?

Yes.



来源:https://stackoverflow.com/questions/2977837/is-an-iteration-on-a-f-map-or-set-in-order-traversal

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