3 ms·
Isn't that the opposite, though? If you store the next/prev pointers in the data structure itself, you can't use the same object in multiple collections. If y
by kelnos 4y ago
Isn't that the opposite, though? If you store the next/prev pointers in the data structure itself, you can't use the same object in multiple collections.
If you have a standalone linked list data structure, then you can, as long as you have a good means of tracking the lifetime of the data itself.
- nirs 4y agoTypically you keep a list entry in the struct: https://man7.org/linux/man-pages/man3/stailq.3.html#EXAMPLES https://man7.org/linux/man-pages/man3/stailq.3.html#EXAMPLES The same list entry can be moved between several lists using the same type. If the struct need to be in multiple lists in the same time you can keep multiple list entries in the same struct: https://github.com/freebsd/freebsd-src/blob/69413598d2660054e29cac9454fe18c08e3bf36d/sys/sys/proc.h#L237 https://github.com/freebsd/freebsd-src/blob/69413598d2660054...