BGC Tools
Static Public Member Functions
BGC.Mathematics.SetOperations Class Reference

Static Public Member Functions

static List< T > Intersection< T > (this List< T > a, List< T > b)
 Finds the list intersection between two lists where each repeated value is unique Intersection is the Or operation More...
 
static List< T > Union< T > (this List< T > a, List< T > b)
 Finds the list union between two lists where each repeated value is unique Union is the And operation More...
 

Detailed Description

Definition at line 6 of file SetOperations.cs.

Member Function Documentation

◆ Intersection< T >()

static List<T> BGC.Mathematics.SetOperations.Intersection< T > ( this List< T >  a,
List< T >  b 
)
inlinestatic

Finds the list intersection between two lists where each repeated value is unique Intersection is the Or operation

Definition at line 12 of file SetOperations.cs.

13  {
14  Dictionary<T, bool> usedValues = new Dictionary<T, bool>();
15  List<T> result = new List<T>();
16 
17  for (int i = 0; i < a.Count; ++i)
18  {
19  if (usedValues.ContainsKey(a[i]) == false)
20  {
21  usedValues.Add(a[i], true);
22  result.Add(a[i]);
23  }
24  }
25 
26  for (int i = 0; i < b.Count; ++i)
27  {
28  if (usedValues.ContainsKey(b[i]) == false)
29  {
30  usedValues.Add(a[i], true);
31  result.Add(b[i]);
32  }
33  }
34 
35  return result;
36  }

◆ Union< T >()

static List<T> BGC.Mathematics.SetOperations.Union< T > ( this List< T >  a,
List< T >  b 
)
inlinestatic

Finds the list union between two lists where each repeated value is unique Union is the And operation

Definition at line 42 of file SetOperations.cs.

43  {
44  return a.Union(b);
45  }

The documentation for this class was generated from the following file: