如何提高Clist.Removeall()的速度 [英] How Can I Improve The Speed Of Clist.Removeall()

查看:133
本文介绍了如何提高Clist.Removeall()的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用模板CList处理大数据,但我发现当数据很大(大约100毫升)时,CList.RemoveAll()的速度非常慢,所以请帮我提高速度。 br />
谢谢!

I'm using templet CList to treat large data,but I find that the speed of CList.RemoveAll() is very slow when the data is large(about 100 millom),so please help me to improve the speed.
thank you!

推荐答案

查看实现显示 CList 节点存储在 CPlex 块中。这些块使用传递给 CList构造函数的块大小参数进行分配[ ^ ]。



使用更大的块大小值将导致更少的内存分配和解除分配,因此将减少执行时间。如果事先知道最大项目数,则可以传递给只有一个大内存分配。



然而, RemoveAll 实现仍将遍历所有需要一段时间的节点。
Having a look at the implementation shows that CList nodes are stored in CPlex blocks. These blocks are allocated using the block size parameter passed to the CList constructor[^].

Using a larger block size value will result in less memory allocations and de-allocations and will therefore reduce the execution time. If the maximum number of items is known in advance, that can be passed to have only one big memory allocation.

However, the RemoveAll implementation will still iterate through all nodes which took some time.


这篇关于如何提高Clist.Removeall()的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆