Intersection

  • Thread starter Thread starter ryu
  • Start date Start date
R

ryu

Hi, May I know how to do an intersection of sets using C#? Where the number
of sets will only be known during runtime. Many Thanks
 
ryu said:
Hi, May I know how to do an intersection of sets using C#? Where the
number of sets will only be known during runtime. Many Thanks

Since .NET does not offer a set class, and C# doesn't offer any set
operations, there is no inherent way to do this. You will have to either
write a set class to perform the work, or define a method that does it over
arrays or lists.

Determining the intersection is pretty easy, just iterate one list and keep
only the elements that exist in all others.
 
If the members of the set are enumerable then they can be represented
by a bitset and anding the bitsets will give the intersection very
easily.
 
rk said:
If the members of the set are enumerable then they can be represented
by a bitset and anding the bitsets will give the intersection very
easily.

Yes, you have a point there. It entirely depends on the size and consistency
of your set universe.
 
Back
Top