News for hackers. Stuff that matters.
Re:Linked List Problems (2002) [pdf] by panic on Saturday November 25, 2017 @04:00AM (#15775123)
C++ folks tend to dislike linked lists because it's awkward to make C++ lists intrusive. The STL list containers store the pointers in a separate allocation from the object itself, so they're slower than they ought to be.
Re:Linked List Problems (2002) [pdf] by haeffin on Saturday November 25, 2017 @04:20AM (#15775175)
Where did you get that? The STL implementations I know definitely don't. See https://github.com/llvm-mirror/libcxx/blob/master/include/li... for an example - __list_node_base contains the pointers, __list_node contains the object and derives from __list_node_base, so allocating the node with object and pointers is one allocation.
Re:Linked List Problems (2002) [pdf] by panic on Saturday November 25, 2017 @05:47AM (#15775420)
Yeah, that's true for values you're willing to allocate inline. The key advantage of intrusive linked lists is being able to add and remove normally allocated objects without having to construct separate list nodes. The STL does have splice(), but it's awkward -- you always have to keep the object in a list and refer to it using iterators instead of normal references.
Re:Linked List Problems (2002) [pdf] by barrkel on Sunday November 26, 2017 @08:46AM (#15780863)
A data structure with the linked list inline is the other way around, e.g.:

    class Foo {
      Foo *m_next;
      Foo *m_next_mru;
      Foo *m_next_sibling;
    };
With the STL implementation, only one list can have the item inlined; all the other linked lists need two indirections to get to the next element.