How to Quickly Remove Items From a List

前端 未结 11 1567
情歌与酒
情歌与酒 2020-11-30 01:45

I am looking for a way to quickly remove items from a C# List. The documentation states that the List.Remove() and List.RemoveAt()<

11条回答
  •  盖世英雄少女心
    2020-11-30 02:05

    Lists are faster than LinkedLists until n gets realy big. The reason for this is because so called cache misses occur quite more frequently using LinkedLists than Lists. Memory look ups are quite expensive. As a list is implemented as an array the CPU can load a bunch of data at once because it knows the required data is stored next to each other. However a linked list does not give the CPU any hint which data is required next which forces the CPU to do quite more memory look ups. By the way. With term memory I mean RAM.

    For further details take a look at: https://jackmott.github.io/programming/2016/08/20/when-bigo-foolsya.html

提交回复
热议问题