set-difference

What is the fastest or most elegant way to compute a set difference using Javascript arrays?

Let A and B be two sets. I'm looking for really fast or elegant ways to compute the set difference (A - B or A \B, depending on your preference) between them. The two sets are stored and manipulated as Javascript arrays, as the title says. Notes: Gecko-specific tricks are okay I'd prefer sticking to native functions (but I am open to ...

Set difference with XPath 1.0 - how do I get .//table without .//table//table?

I'm trying to find all the tables below my current node without also including the nested tables. In other words, if I have this, i want to find "yes" and not "no": <table> <!-- outer table - no --> <tr><td> <div> <!-- *** context node *** --> <table> <!-- yes --> <tr><td> <table> ... </table> <!-- no --> ...

Find String Array Difference in Java

I created two array variables: s1 and s2 s1 contains {ram,raju,seetha} s2 contains {ram} I want to subtract the two arrays as sets, in order to get the following result: raju seetha How can I do this? ...

bash, Linux: Set difference between two text files

Hi, I have two files A-nodes_to_delete and B-nodes_to_keep. Each file has a many lines with numeric ids. I want to have the list of numeric ids that are in nodes_to_delete but NOT in nodes_to_keep, e.g. . Doing it within a PostgreSQL database is unreasonably slow. Any neat way to do it in bash using Linux CLI tools? UPDATE: This woul...

MySQL: difference of two result sets

How can I get the set difference of two result sets? Say I have a result set (just one column in each): result1: 'a' 'b' 'c' result2: 'b' 'c' I want to minus what is in result1 by result2: result1 - result2 such that it equals: difference of result1 - result2: 'a' ...

c++ Difference between two vector<MyType*> A and B

Dear reader, I've got two vector<MyType*> objects called A and B. The MyType class has a field ID and I want to get the MyType* which are in A but not in B. I'm working on a image analysis application and I was hoping to find a fast/optimized solution. Kind regards, Pollux ...

How do I delete the intersection of sets A and B from A without sorting in MATLAB?

Two matrices, A and B: A = [1 2 3 9 7 5 4 9 4 1 4 7] B = [1 2 3 1 4 7] All rows of matrix B are members of matrix A. I wish to delete the common rows of A and B from A without sorting. I have tried setdiff() but this sorts the output. For my particular problem (atomic coordinates in protein structures) maintaini...