Comparing Huge Files using C++
I have two big text Files each having more than 10 Million lines. How can i compare the files and get different lines in the files using C++.
I have tried loading one file into memory and sorted the memory and used the binary tree logic to compare the files. It compared and gave me the result in 20 Sec. But it's consuming more memory. (The text file is around 500 MB).
I want to compare two files without consuming more memory, a Good Performance and to have minimal effects on Hard Disk.
you can use a two pass method.
first pass, you read files but only store hash value and line start pos of lines, then u can compare files based on hash value, you only read the lines again for complete compare in the second pass when two lines have same hash value. this will save memory consumption and cpu time, with a bit penalty to read some lines twice.
链接地址: http://www.djcxy.com/p/62348.html上一篇: 根据RGB值更改图像的颜色
下一篇: 使用C ++比较大文件