English 中文(简体)
一种比简单的病媒更快的环状病媒?
原标题:How is a bitmapped vector trie faster than a plain vector?

http://www.infoq.com/presentations/Functional-Data-Structures-in-Scala” rel=“noreferer”比病媒更快,但我并不真正理解参考地点如何帮助(因为病媒按定义是当地包装最容易的数据——每个要素都在后面的内容下包装,没有额外的空间)。

基准是否假定某种特定使用模式或类似做法?

如何做到这一点?

最佳回答

在其他答复中,有许多良好之处,但你的问题没有得到答案。 旁观者只是按指数(当阵列大小时)对随机检查的批量迅速。 你们可能会问“怎么做? “通常的平方阵只需要移动点,而长者必须穿过多个步骤......

答案是“Cache Locality”。

海滩总是从记忆中抽取。 如果你有一大阵列,它就不适于海滩。 因此,如果你想拿到物品x和物品,你就必须重载整个海滩。 这是因为这些阵列永远是连续的记忆。

如今,光辉者却.。 周围有许多小阵列,而联合核查机制对此很.,相互接近。 因此,随机接触速度快;如果通过随机接触,则速度要慢得多。

我必须说,我不是硬件专家,也不是科索沃信托机构如何处理切身之处的专家,我从来没有把这一点作为基准。

Edit: mikera也提到这一点。

Edit2:如果你只是在病媒中弹 the,见关于功能数据结构的论述,即: http://www.infoq.com/presentations/Functional-Data-Structures-in-Scala。

问题回答

环形矢量(aren t)严格比正常病媒更快,至少在一切方面都如此。 这取决于你们正在考虑什么行动。

例如,常规病媒在获得特定指数的数据要素方面较快。 它很难进行简单的指数化阵列调查。 从切身地方的角度来看,如果你们所有这样做都顺从,那么大阵列就非常好。

然而,其他业务(与结构分享相比)的环绕矢量三角将大大加快,例如,在不影响到原始数据结构的情况下,为传统病媒制作一份带有单一变化成分的新版本,即O(log32 n)和O(n)。 这是巨大的胜利。

这里有一个很好的录像,值得观察这个专题,其中包括你为什么希望用你的语言建立这种结构的许多动机:。 固定数据结构和管理参考资料 (由Rich Hickey教授)。

由Rich Hickey为克隆技术发明的数据结构,自2010年起在Schala(五2.8)实施。 它是其“bitwise indexing战略”,能够高效地获取和修改大型数据集。

From Understanding Clojure s Persistent Vectors :

Mutable vectors and ArrayLists are generally just arrays which grows and shrinks when needed. This works great when you want mutability, but is a big problem when you want persistence. You get slow modification operations because you ll have to copy the whole array all the time, and it will use a lot of memory. It would be ideal to somehow avoid redundancy as much as possible without losing performance when looking up values, along with fast operations. That is exactly what Clojure s persistent vector does, and it is done through balanced, ordered trees.

The idea is to implement a structure which is similar to a binary tree. The only difference is that the interior nodes in the tree have a reference to at most two subnodes, and does not contain any elements themselves. The leaf nodes contain at most two elements. The elements are in order, which means that the first element is the first element in the leftmost leaf, and the last element is the rightmost element in the rightmost leaf. For now, we require that all leaf nodes are at the same depth2. As an example, take a look at the tree below: It has the integers 0 to 8 in it, where 0 is the first element and 8 the last. The number 9 is the vector size:

enter image description here

If we wanted to add a new element to the end of this vector and we were in the mutable world, we would insert 9 in the rightmost leaf node, like this:

“entergraph

But here s the issue: We cannot do that if we want to be persistent. And this would obviously not work if we wanted to update an element! We would need to copy the whole structure, or at least parts of it.

To minimize copying while retaining full persistence, we perform path copying: We copy all nodes on the path down to the value we re about to update or insert, and replace the value with the new one when we re at the bottom. A result of multiple insertions is shown below. Here, the vector with 7 elements share structure with a vector with 10 elements:

“entergraph

The pink coloured nodes are shared between the vectors, whereas the brown and blue are separate. Other vectors not visualized may also share nodes with these vectors.


More info

<http://hypirion.com/musings/underpersistent-vector-pt-1”rel=“nofollow noreferer”> Underent Clojure s Persistent Vectors,该数据结构及其使用案例背后的想法也在David Nolen s2014年讲座Ideal Hashubes

“Persistent

“解释病媒”指的是什么? 仅是一整块物品? 如果你永远不更新,但如果你改变1M-element的统一制导器,你必须做许多复制件;树木的存在使你能够分享大部分结构。

根据谈话标题判断,它谈论的是Scala <<> 病媒,这些病媒甚至接近“当地最包装的数据”:见来文方 at

你的定义只适用于特许证(据我所知)。





相关问题
The Fastest DataStructure to Filter with in C#

Currently we are filtering and sorting data with a datatable. /// <summary> /// Filters the data table and returns a new data table with only the filtered rows. /// </summary>...

Efficient queue in Haskell

How can I efficiently implement a list data structure where I can have 2 views to the head and end of the list, that always point to a head a tail of a list without expensive calls to reverse. i.e: ...

Java large datastructure for storing a matrix

I need to store a 2d matrix containing zip codes and the distance in km between each one of them. My client has an application that calculates the distances which are then stored in an Excel file. ...

Holding onto items after a postback

I have an ASP.NET web application and I want to be able to take items from a master list and store them temporarliy into one of four other lists. The other lists need to survive post backs so that ...

negative number in the stack

I am a new student in the compilers world ^_^ and I want to know is legal represent negative number in the stack. For example: infix: 1-5=-4 postfix: 15- The statements are: push(1) push(5) x=...

What type of struct/container would you use in this instance?

I am trying to figure out what type of structure or container I should use for a quick project. I need to have an unknown number of sets that will be entered from the GUI (each one will have a name, ...