Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set operation in .NET C#

I'm working on a something related to roughset right now. The project uses alot of sets operation and manipulation. I've been using string operations as a stop gap measure for set operation. It has worked fine until we need to process some ungodly amount of data ( 500,000 records with about 40+ columns each ) through the algorithm.

I know that there is no set data structure in .net 2.0(2.0 was the latest when I started the project) I want to know if there is any library that offer fast set operation in .net c# or if 3.5 has added native set data structure.

Thanks .

like image 927
paan Avatar asked Sep 22 '08 04:09

paan


3 Answers

.NET 3.5 already has a native set data type: HashSet. You might also want to look at HashSet and LINQ set operators for the operations.

In .NET 1.0, there was a third party Set data type: Iesi.Collections which was extended with .NET 2.0 generics with Iesi.Collections.Generic.

You might want to try and look at all of them to see which one would benefit you the most. :)

like image 175
Jon Limjap Avatar answered Sep 22 '22 18:09

Jon Limjap


LINQ supports some set operations. See LINQ 101 page for examples.
Also there is a class HashSet (.NET 3.5)


Here is Microsoft guidelines for set operations in .NET:

HashSet and LINQ Set Operations

List of set operations supported by HasSet class:

HashSet Collection Type

like image 40
aku Avatar answered Sep 20 '22 18:09

aku


Update: This is for .Net 2.0. For .Net 3.5, refer posts by aku, Jon..

This is a good reference for efficiently representing sets in .Net.

like image 33
Gulzar Nazim Avatar answered Sep 20 '22 18:09

Gulzar Nazim