Why does cache locality matter for array performance?

See my answer about spatial and temporal locality. In particular, arrays are contiguous memory blocks, so large chunks of them will be loaded into the cache upon first access. This makes it comparatively quick to access future elements of the array. Linked lists on the other hand aren’t necessarily in contiguous blocks of memory, and could … Read more

Debug assertion failed

The problem is that the function list::Subset(list subset) takes its argument by value causing a copy of the list to be made. Since you did not follow the Rule of Three (as noted in Chris’ comment) a shallow copy is made. This means that two instance of list “own” the pointers. When the Subset function … Read more