|
|
|
|
|
by immibis2
20 days ago
|
|
Don't. Take every measure to avoid them and use more dynamic arrays (vectors) instead. A dynamic array of pointers still beats a linked list, since the pointers don't form a serial dependency chain. Either a dynamic array of values or a dynamic array of pointers should be your go-to data structure until something else is indicated - just like linked lists used to be. Don't be too afraid of inserts in the middle - benchmark it to be sure, but you shuffle 100-1000 entries in a dynamic array in the time it can read 1-2 list nodes (with clear cache in both cases). The performance difference is so utterly insane that you need to avoid linked lists at all costs. |
|