set-operations

Finding Set Complement in Unix

Given this two files: $ cat A.txt $ cat B.txt 3 11 5 1 1 12 2 3 4 2 I want to find lines number that is in A "BUT NOT" in B. What's the unix command for it? I tried this but seems to fail: comm -3 <(sort -n A.txt) <(sort -n B.txt) | sed 's/\t//g' ...

Quickest way to find the complement of two collections in C#

I have two collections of type ICollection; c1 and c2. I'd like to find the set of items that are in c2 that are not in c1 where the heuristic for equality is the Id property on MyType. What is the quickest way to perform this in C#. Edit: C# version = 3.0 ...

Union, intersect, difference large IntSet in O(m+n) times

from my question http://stackoverflow.com/questions/3601472/insert-element-to-arraylist-with-ascending-order-and-no-duplicate-elements i've done my insert method. Now i try to find out union, intersect, and difference method to operate 2 IntSet. Notice that number elements of IntSet is large and i need to do it in O(m+n) time where ...