How to Optimize the Pattern Matching search

M

m.muthukareem

Hi

Sub: I need an idea about, To optimize the search of function
declaration present in two different source.


I have collected the function declarations from c program headers on
two different operating system. Now, i have to look for absence of
all functions declaration in any given application w.r.t. other
operating system. The major issue is once an function declaration is
fetched from application, we need to search in entire input file for
the absence of similar function. The process repeats for other
functions declaration recursively by reading the same input file from
top to bottom. So Could any of you give proper suggestion on how to
optimize the search.
 
T

Tad McClellan

Hi

Sub: I need an idea about, To optimize the search of function
declaration present in two different source.


I have collected the function declarations from c program headers on
two different operating system.


Then you don't need help with pattern matching.

Why does your subject mention it then?

Now, i have to look for absence of
all functions declaration in any given application w.r.t. other
operating system.


From the Perl FAQ:

How do I compute the difference of two arrays? How do I compute the
intersection of two arrays?

Use a hash. Here’s code to do both and more. It assumes that each eleâ€
ment is unique in a given array:

@union = @intersection = @difference = ();
%count = ();
foreach $element (@array1, @array2) { $count{$element}++ }
foreach $element (keys %count) {
push @union, $element;
push @{ $count{$element} > 1 ? \@intersection : \@difference }, $ele
ment;
}

Note that this is the symmetric difference, that is, all elements in
either A or in B but not in both. Think of it as an xor operation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top