Answer the question
In order to leave comments, you need to log in
How to compare the data of two arrays of text?
There are:
1st file, to which the patterns of removing the text form are set.
Structure of the 1st:
/dir1/dir2/folder1/ file.exec
30: debag.0
45: test1.0
1789: type.0 Numbered
data (30: debag.) preserving its path (/home/dir1) in the form /folder1/ ) should be compared with the array of the 2nd file, which looks like:
/dir1/dir2/folder1/ debag.0
/dir1/dir2/folder1/ test1.0
/dir1/dir2/folder1/
type.0 if the required line of the 1st file is missing in the list of the 2nd file, the 3rd file is formed, with the difference entered into it:
1-й 2-й 3-й
/dir1/dir2/folder1/ file.exec
l30: debag.0 /dir1/dir2/folder1/ debag.0
45: test1.0 /dir1/dir2/folder1/ test1.0
1789: type.0 /dir1/dir2/folder1/ type.0
Answer the question
In order to leave comments, you need to log in
Mmm, I'm not very good at algorithms (not at all), but as for me - sort the second array and cycle through selecting rows from the first array, bring them to the form expected in the second array (path prefix and discarding the number designation) and look for binary search occurrence of these lines. You sort the second array, for example, with quicksort or merge sort.
UPD. And it's even better to bring the strings in the second and first arrays to a single form, I think so, this is if the directory usually takes more characters than the file name, cutting off the prefix at the first occurrence of path separator char from the end. There will be fewer checks for matching characters in two strings.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question