Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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!
Posted
Comments
Kornfeld Eliyahu Peter 30-Mar-15 4:46am    
If you remove all items, you may drop the whole object and create a new - empty - instance...
hanxingde 30-Mar-15 5:20am    
then,how i can drop the whole object? if i do not use RemoveAll(),how can i free the the memory it take?
Jochen Arndt 30-Mar-15 7:07am    
This would not help because the CList destructor calls RemoveAll().
Richard MacCutchan 30-Mar-15 5:03am    
You cannot change the laws of physics. !00,000,000 items in a list will take 100,000,000 times a small finite time, which results in a larger time, to be removed. You may need to rethink your design.
hanxingde 30-Mar-15 5:27am    
thank you for replying me,but i have no idea on treating large data,if i don't use CList,what can i instead of it?CArray? I think they all have no quick speed to delete so many data.can you help me in designing?

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900