作者:胖肉肉520 | 来源:互联网 | 2023-05-19 17:39
I have a LinkedList with big size (3912984 or more) and I wanna copy these elements in a byte array. The integers are 0 or 1, so I don't need any change of size for array, I want just to copy elements one by one, exactly how they are. Of course, I know the simplest way is :
我有一个大尺寸(3912984或更大)的LinkedList
,我想在一个字节数组中复制这些元素。整数是0或1,所以我不需要更改数组的大小,我只想逐个复制元素,确切地说它们是如何。当然,我知道最简单的方法是:
for(int i = 0; i
But this method is too slow and my program doesn't end before hours ! Can you know another way (faster, something like Buffer.BlockCopy() of .NET) or I have to change data structures?
但这种方法太慢了,我的程序不会在数小时前结束!你能知道另一种方式(更快,像.NET的Buffer.BlockCopy())或者我必须改变数据结构吗?
2 个解决方案