// <summary> // Performs an `and' operation on the bit vector. The `new_vector' may have // a different size than the current one. // </summary> private MyBitVector And (MyBitVector new_vector) { if (Count == 0) return this; var o = new_vector.vector != null ? new_vector.vector : new_vector.shared; if (o == null) { for (int i = new_vector.Count; i < Count; ++i) this [i] = false; return this; } if (o.Count == 0) { SetAll (false); return this; } if (Count == o.Count) { if (vector == null) { if (shared == null) { shared = new_vector.MakeShared (Count); return this; } initialize_vector (); } vector.And (o); return this; } int min = o.Count; if (Count < min) min = Count; for (int i = 0; i < min; i++) { if (! o [i]) this [i] = false; } for (int i = min; i < Count; i++) this [i] = false; return this; }
public MyBitVector (MyBitVector InheritsFrom, int Count) { if (InheritsFrom != null) shared = InheritsFrom.MakeShared (Count); this.Count = Count; }