[英]Does Data.Vector replace Data.Sequence?
I've been quite a fan of Data.Sequence . 我一直很喜欢Data.Sequence 。 But as I've been learning about Data.Vector , it seems that it can do everything Data.Sequence can, but better, plus it can do more stuff.
但是,由于我一直在学习Data.Vector ,它似乎可以做Data.Sequence可以做的一切,但更好,再加上它可以做更多的东西。 Should we be deprecating Data.Sequence and preaching Data.Vector?
我们应该弃用Data.Sequence并讲道Data.Vector吗? Are there any good reasons for using Data.Sequence over Data.Vector?
在Data.Vector上使用Data.Sequence有什么好的理由吗?
None of these data structures can replace the other; 这些数据结构都不能取代另一个;
Data.Sequence
and Data.Vector
are actually at diametrically opposite ends of the data structures available for representing sequences. Data.Sequence
和Data.Vector
实际上位于可用于表示序列的数据结构的两端。
Data.Vector
is a contiguous array of elements. Data.Vector
是一个连续的元素数组。 This means small memory footprint and O(1) lookup but terrible mutation, concatenation and copying (O(n) each). Data.Sequence
on the other hand is a purely functional tree. Data.Sequence
是一个纯粹的功能树。 This means higher memory usage and less locality, but it supports fast access and mutation O(log n) and awesome concatenation O(log(min(n1,n2))) and copying. The choice of data structure really depends on the task at hand here. 数据结构的选择实际上取决于此处的任务。
Data.Vector
. Data.Vector
。 Data.Sequence
. Data.Sequence
。 Sharing a prefix seems like something Seq
is better at than Vector
. 共享前缀似乎是
Seq
比Vector
更好的东西。 snoc
on Vector
is O(n). snoc
上Vector
为O(n)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.