Displaying 1 result from an estimated 1 matches for "listhalfnod".
Did you mean:
listhalfnode
2015 Oct 08
5
ilist/iplist are broken (maybe I'll fix them?)
...-----------
It gets worse though :(.
This still wastes a pointer compared to the naive list. Many uses of
iplist/ilist make a further optimization to win back that pointer,
splitting `ListNode<T>` into two, and using only half the node for the
sentinel.
template <class T> struct ListHalfNode { T *prev; };
template <class T> struct ListNode : ListHalfNode<T> { T *next; };
template <class T> struct List {
ListHalfNode<T> Sentinel;
T *Head = static_cast<T *>(&Sentinel);
void ensureHead() {}
};
Besides exposing the same UB a...