public virtual void DifferenceWithTest() { // Test arrayContainer-based sets int[] set1 = { 1, 2, 3, 7 }; RoaringBitset testSet1 = RoaringBitset.Create(set1); int[] set2 = { 1, 4, 7 }; RoaringBitset testSet2 = RoaringBitset.Create(set2); testSet1.DifferenceWith(testSet2); Assert.AreEqual(false, testSet1.Get(1)); Assert.AreEqual(true, testSet1.Get(3)); // Test bitsetContainer-based sets int[] set3 = SetGenerator.GetContiguousArray(0, 5000); RoaringBitset testSet3 = RoaringBitset.Create(set3); int[] setExceptions = { 4 }; int[] set4 = SetGenerator.GetContiguousArrayWithExceptions(0, 5000, setExceptions); RoaringBitset testSet4 = RoaringBitset.Create(set4); // Reduce contiguous array to single value (4) via DifferenceWith testSet3.DifferenceWith(testSet4); Assert.AreEqual(false, testSet3.Get(2)); Assert.AreEqual(true, testSet3.Get(4)); // // Reduce testSet2 to 4 as well testSet2.DifferenceWith(testSet4); Assert.AreEqual(false, testSet2.Get(1)); Assert.AreEqual(true, testSet2.Get(4)); // Remove contents of set1 from set4 testSet4.DifferenceWith(testSet1); Assert.AreEqual(false, testSet4.Get(2)); Assert.AreEqual(true, testSet4.Get(6)); }
static void Main(string[] args) { RoaringBitset rb = RoaringBitset.Create(1, 4, 5, 6); RoaringBitset rb2 = new RoaringBitset(); rb2.Add(5000, 5255); RoaringBitset rbOr = RoaringBitset.Or(rb, rb2); rb.OrWith(rb2); Debug.Assert(rbOr.Equals(rb), "Expected inplace OrWith to be equal to standard Or"); long cardinality = rb.Cardinality(); Debug.Assert(cardinality == 259, "Cardinality should be 259"); Console.WriteLine("Printing values..."); foreach (int i in rb) { Console.WriteLine(i); } }
protected override IBitset CreateSetFromIndices(int[] indices, int length) { return(RoaringBitset.Create(indices)); }