Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Theory and .NET

Recently I came across a situation where set theory and set math fit what I was doing to the letter (granted there was an easier way to accomplish what I needed - i.e. LINQ - but I didn't think of that at the time). However I didn't know of any generic set libraries. Granted IEnumerables provide some set operations (Union, etc.), but nothing like Intersection or set comparison. Can anyone point out something that fits here? Something that implements set math using a generic type?

like image 252
CodeMonkey1313 Avatar asked May 24 '10 11:05

CodeMonkey1313


People also ask

Is set theory used in computer programming?

Set Theory is indivisible from Logic where Computer Science has its roots. It has been and is likely to continue to be a a source of fundamental ideas in Computer Science from theory to practice; Computer Science, being a science of the artificial, has had many of its constructs and ideas inspired by Set Theory.

What is the use of set theory in real life?

Set theory is used extensively in mathematics. It serves as the foundation for many mathematical subfields. It is used extensively in statistics, particularly in probability. Many notions in probability are drawn from set theory's consequences.

Is set theory still used?

Set theory is commonly employed as a foundational system for the whole of mathematics, particularly in the form of Zermelo–Fraenkel set theory with the axiom of choice.

What is the use of set theory in business?

Applied to business operations, set theory can assist in planning and operations. Every element of business can be grouped into at least one set such as accounting, management, operations, production and sales. Within those sets are other sets.


2 Answers

There is HashSet<T> in the framework (3.5+) that does what you need. .NET 4 also introduced SortedSet<T> and a common interface ISet<T>.

like image 126
Julien Lebosquain Avatar answered Oct 04 '22 20:10

Julien Lebosquain


System.Collections.Generic.HashSet has a number of set operations including Subset, Superset,Intersection,Union etc.

http://msdn.microsoft.com/en-us/library/bb359438.aspx

I hope this helps

joe

like image 29
Joe Simmonds Avatar answered Oct 04 '22 20:10

Joe Simmonds