Functional data structures in C++

蹲街弑〆低调 提交于 2019-12-17 23:32:23

问题


Does anyone know of a C++ data structure library providing functional (a.k.a. immutable, or "persistent" in the FP sense) equivalents of the familiar STL structures?

By "functional" I mean that the objects themselves are immutable, while modifications to those objects return new objects sharing the same internals as the parent object where appropriate.

Ideally, such a library would resemble STL, and would work well with Boost.Phoenix (caveat- I haven't actually used Phoenix, but as far as I can tell it provides many algorithms but no data structures, unless a lazily-computed change to an existing data structure counts - does it?)


回答1:


I would look and see whether FC++ developed by Yannis Smaragdakis includes any data structures. Certainly this project more than any other is about supporting a functional style in C++.




回答2:


This is more of a heads up than a detailed answer, but Bartosz Milewski appears to have done a lot of work on this. See, for example:

http://bartoszmilewski.com/2013/11/13/functional-data-structures-in-c-lists/

Looks like he's implemented a lot of algorithms from Okasiki's book Purely Functional Data Structures here:

https://github.com/BartoszMilewski/Okasaki

N.B. I haven't tried these yet, but they're the first C++ persistent data structures I've seen outside of FC++.

Hopefully, I'll get to trying them soon.



来源:https://stackoverflow.com/questions/2757278/functional-data-structures-in-c

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