在Haskell稀疏数组? [英] Sparse arrays in Haskell?

查看:131
本文介绍了在Haskell稀疏数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有标准或最常用的方式重新在Haskell present多维稀疏数组(不牺牲性能的太多了)?

Is there any standard or "most usual" way to represent multidimensional sparse arrays in Haskell (without sacrificing performance too much)?

喜欢的东西地图< INT,地图< INT,MyClass的>>在C ++中,例如。我GOOGLE了,发现只是一些老学术论文和其他人要求这一点。

Something like map< int, map< int, MyClass> > in C++, for example. I've Googled and found just some old academic papers and other people asking for this too.

谢谢!

推荐答案

Data.Map中(INT,INT)MyClass的是一个很好的建议;试试先。

Data.Map (Int,Int) MyClass is an excellent suggestion; try that first.

如果您遇到与空间问题,请尝试 IntMap(IntMap MyClass的) IntMap S(模块 Data.IntMap )的地图 s的内部能够像钥匙;被专门它们比一般的地图更加有效。它可能会或可能不会让一个显著差异。

If you run into space problems with that, try IntMap (IntMap MyClass). IntMaps (in module Data.IntMap) are Maps with Ints as keys; being specialised they are more efficient than generic maps. It might or might not make a significant difference.

有也是可扩展,自适应持续容器类型项目,该项目可能是对你有用的。这些容器(包括地图)使用非正常的地图显著的空间较小,但他们稍微复杂一些(尽管仍然在使用相当容易)。

There is also the Scalable, adaptive persistent container types project which might be of use to you. Those containers (including maps) use significantly less space than normal maps but they are slightly more complicated (although still reasonably easy in use).

这篇关于在Haskell稀疏数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆