paraboul 6 days ago

> the same object can be part of multiple containers at once

I'm not sure I understand this one. Since the object contains the reference to where it belongs inside a container (e.g. object.node.next) how can it be re-used in multiple containers. Conversely, in a non-intrusive data structure, multiple containers can hold a ref to the same object through an intermediate node object

2
gnubison 6 days ago

You add multiple next variables. buffer.next, buffer.next_displayed, etc

paraboul 6 days ago

That's not an advantage of intrusive data structures then. That's precisely an advantage of non-intrusive data structure : object can be inserted in an arbitrary number of containers

mikepurvis 6 days ago

But for the intrusive one you have the visibility into its membership in the other structures, since you're holding a reference to the object and its intrusive fields.

In the non-intrusive case, all you know is how you got there, you don't have return info to the other structures— particularly annoying if you're trying to destroy an object and have to speculatively look for references to it in the other lists in order to get rid of them.

paraboul 5 days ago

Of course. But I wouldn’t qualify "multi-container use" to be an advantage of intrusive data structures per se.

dlahoda 4 days ago

when zig people say multicontainer use, they mean C use, not O(log N) nor O(1)( which may be O(N) for small data). but very strict C.

Zambyte 6 days ago

The object can contain multiple intrusive node fields.