Exemple #1
0
 private SymSet Expand(SymSet old, int newSize)
 {
     SymSet expandedSet = old.Copy();
       if (newSize > old.bitSet.Length) expandedSet.bitSet.Length = newSize;
       return expandedSet;
 }
Exemple #2
0
 public SymSet SymDiff(SymSet that)
 {
     // Set symmetric difference
       int commonSize = max(this.bitSet.Length, that.bitSet.Length);
       SymSet one = Expand(this, commonSize);
       SymSet two = Expand(that, commonSize);
       return new SymSet(one.bitSet.Xor(two.bitSet));
 }
Exemple #3
0
 public SymSet Union(SymSet that)
 {
     // Set union
       int commonSize = max(this.bitSet.Length, that.bitSet.Length);
       SymSet one = Expand(this, commonSize);
       SymSet two = Expand(that, commonSize);
       return new SymSet(one.bitSet.Or(two.bitSet));
 }
Exemple #4
0
 /*
 public SymSet Intersection(SymSet that) {
 // Set intersection
   int commonSize = max(this.bitSet.Length, that.bitSet.Length);
   SymSet one = Expand(this, commonSize);
   SymSet two = Expand(that, commonSize);
   return new SymSet(one.bitSet.And(two.bitSet));
 } // SymSet.intersection
   */
 public SymSet Intersection(SymSet that)
 {
     // Set intersection
       int minSize = min(this.bitSet.Length, that.bitSet.Length);
       SymSet one = new SymSet(minSize);
       for (int i = 0; i < minSize; i++) one.bitSet[i] = this.bitSet[i]  && that.bitSet[i];
       return one;
 }
Exemple #5
0
 public bool Equals(SymSet that)
 {
     // Value comparison - sets contain same elements
       if (that == null) return false;
       int commonSize = max(this.bitSet.Length, that.bitSet.Length);
       SymSet one = Expand(this, commonSize);
       SymSet two = Expand(that, commonSize);
       for (int i = 0; i < commonSize; i++)  {
     if (one.bitSet[i] != two.bitSet[i]) return false;
       }
       return true;
 }
Exemple #6
0
 /*
 public SymSet Difference(SymSet that) {
 // Set difference
   int commonSize = max(this.bitSet.Length, that.bitSet.Length);
   SymSet one = Expand(this, commonSize);
   SymSet two = Expand(that, commonSize);
   for (int i = 0; i < commonSize; i++) one.bitSet[i] = one.bitSet[i]  && ! two.bitSet[i];
   return one;
 } // SymSet.Difference
   */
 public SymSet Difference(SymSet that)
 {
     // Set difference
       int minSize = min(this.bitSet.Length, that.bitSet.Length);
       SymSet one = this.Copy();
       for (int i = 0; i < minSize; i++) one.bitSet[i] = one.bitSet[i]  && ! that.bitSet[i];
       return one;
 }
Exemple #7
0
 public bool Contains(SymSet that)
 {
     // Returns true if that is a subset of this set
       return that.IsEmpty() || that.Difference(this).IsEmpty();
 }
Exemple #8
0
 // Empty set constructor
 public SymSet(SymSet old)
 {
     // Construct set from old
       this.bitSet = new BitArray(old.bitSet);
 }