这是什么意思为数据结构要"侵入"? [英] What does it mean for a data structure to be "intrusive"?

查看:277
本文介绍了这是什么意思为数据结构要"侵入"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过的长期的侵入的用来形容像列表和堆栈数据结构,但它是什么意思?

I've seen the term intrusive used to describe data structures like lists and stacks, but what does it mean?

你能不能举一个侵入数据结构的code为例,它从一个非侵入一个人如何区别?

Can you give a code example of an intrusive data structure, and how it differs from a non-intrusive one?

此外,为什么让它侵入(或,非侵入式)?有什么好处?有什么缺点?

Also, why make it intrusive (or, non-intrusive)? What are the benefits? What are the disadvantages?

推荐答案

这是侵入性的数据结构是一个需要帮助的打算,以便存储的元素来存储它们。

An intrusive data structure is one that requires help from the elements it intends to store in order to store them.

让我改写了。当你把东西放到该数据结构,即东西就知道的事实,这是该数据结构,以某种方式。添加元素的数据结构改变的元素。

Let me reword that. When you put something into that data structure, that "something" becomes aware of the fact that it is in that data structure, in some way. Adding the element to the data structure changes the element.

有关实例,可以构建一个非侵入二叉树,其中每个节点有到左和右子树的引用,并且该节点的元素值的基准

For instance, you can build a non-intrusive binary tree, where each node have a reference to the left and right sub-trees, and a reference to the element value of that node.

或者,您可以建立一个侵入之一,这些子树的引用被嵌入到本身的价值。

Or, you can build an intrusive one where the references to those sub-trees are embedded into the value itself.

的侵入的数据结构的一个例子是,是可变的元素的有序列表。如果元素改变,列表需要被重新排序,因此列表对象必须以获得他们的合作的元件的隐私侵犯。 IE浏览器。该元素有了解的名单是在,并告知它的变化。

An example of an intrusive data structure would be an ordered list of elements that are mutable. If the element changes, the list needs to be reordered, so the list object has to intrude on the privacy of the elements in order to get their cooperation. ie. the element has to know about the list it is in, and inform it of changes.

ORM系统通常围绕侵入性的数据结构,以尽量减少过大的对象列表迭代。例如,如果您检索数据库中的所有员工的列表,然后更改其中一人的名字,并要回保存到数据库中,当雇员对象改变了,因为员工的侵扰名单将被告知对象知道它是在哪个列表。

ORM-systems usually revolve around intrusive data structures, to minimize iteration over large lists of objects. For instance, if you retrieve a list of all the employees in the database, then change the name of one of them, and want to save it back to the database, the intrusive list of employees would be told when the employee object changed because that object knows which list it is in.

一个非侵入式的列表将不会被告知,并且必须要弄清楚什么改变,它本身是如何改变。

A non-intrusive list would not be told, and would have to figure out what changed and how it changed by itself.

这篇关于这是什么意思为数据结构要"侵入"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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