4 ms·
Because (doubly) linked lists can do something an array cannot? Like join operations in O(1)? Or removing an arbitrary element in O(1) once you have its handle?
by dozzie 10y ago
Because (doubly) linked lists can do something an array cannot? Like join operations in O(1)? Or removing an arbitrary element in O(1) once you have its handle?
- blibble 10y agoif it's unordered (like you'd expect a list of sockets to be) you can get O(1) removal for an array by swapping the end item into the removed slot
- dozzie 10y ago...unless something else holds a pointer to the handle you're swapping with.
- blibble 10y agokernels don't tend to give userspace raw pointers into kernel memory
- staticassertion 10y agoThis is already a problem if you're removing an item, regardless of whether it's done with swap remove or not.
- toast0 10y agoFor the item you're removing, you are presumably removing it because all handles have been closed. But the item you're potentially swapping with may certainly have open handles.
- staticassertion 10y agoTrue.