Large mutable byte array in Erlang

后端 未结 3 1367
梦如初夏
梦如初夏 2021-02-14 22:08

As I am writing a simple Minecraft server application in Erlang, I am now concerned with the question of how to efficiently store and modify chunk data. For those who don\'t kno

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-14 23:06

    My suggestion is to use a "rope" structure. Basically a tree-like structure, usually a splay or finger tree in which you allow to change parts of the tree only. Doing this the right way allows you to have the best of both worlds: immutability together with fast updates.

    I don't know of a rope-implementation, but this is what you want to do.

    An alternative is to use ets as a mutable array. It is quite fast for that kind of thing.

    The third option is to use a spatial tree-structure to represent your world. Octrees or a BSP-like structure is something I'd grab for, blindly.

提交回复
热议问题