public static void Main(string[] args) { //RunAllTests(); var ewahBitmap1 = EwahCompressedBitArray.BitmapOf(345, 100987, 4309222); var ewahBitmap1_clone = EwahCompressedBitArray.BitmapOf(345, 100987, 4309222); var ewahBitmap1_strictSubset = EwahCompressedBitArray.BitmapOf(345, 100987); var ewahBitmap1_notstrictSubset2 = EwahCompressedBitArray.BitmapOf(100987, 7007); var ewahBitmap1_intersects_1 = EwahCompressedBitArray.BitmapOf(345, 67773, 100987); var ewahBitmap1_intersects_2 = EwahCompressedBitArray.BitmapOf(65, 345); var ewahBitmap1_3 = EwahCompressedBitArray.BitmapOf(55, 900000008); Console.WriteLine(ewahBitmap1_clone.IsSubsetOf(ewahBitmap1)); Console.WriteLine(ewahBitmap1.IsSubsetOf(ewahBitmap1_clone)); Console.WriteLine(ewahBitmap1.Equals(ewahBitmap1_clone)); Console.WriteLine(ewahBitmap1_strictSubset.IsSubsetOf(ewahBitmap1)); Console.WriteLine(ewahBitmap1_notstrictSubset2.IsSubsetOf(ewahBitmap1)); Console.WriteLine(ewahBitmap1_intersects_1.IsSubsetOf(ewahBitmap1)); Console.WriteLine(ewahBitmap1_intersects_2.IsSubsetOf(ewahBitmap1)); Console.WriteLine(ewahBitmap1.Minus(ewahBitmap1_strictSubset)); Console.WriteLine(ewahBitmap1.Minus(ewahBitmap1_intersects_1)); Console.WriteLine(ewahBitmap1.Minus(ewahBitmap1_intersects_2)); Console.WriteLine(ewahBitmap1.Minus(ewahBitmap1_3)); }
public static void Main(string[] args) { var ewahBitmap1 = EwahCompressedBitArray.BitmapOf(0, 2, 64, 1 << 30); var ewahBitmap2 = EwahCompressedBitArray.BitmapOf(1, 3, 64, 1 << 30); Console.WriteLine("Running demo program:"); Console.WriteLine("bitmap 1: " + ewahBitmap1); Console.WriteLine("bitmap 2:" + ewahBitmap2); EwahCompressedBitArray orbitmap = ewahBitmap1.Or(ewahBitmap2); Console.WriteLine(); Console.WriteLine("bitmap 1 OR bitmap 2:" + orbitmap); Console.WriteLine("memory usage: " + orbitmap.SizeInBytes + " bytes"); Console.WriteLine(); EwahCompressedBitArray andbitmap = ewahBitmap1.And(ewahBitmap2); Console.WriteLine("bitmap 1 AND bitmap 2:" + andbitmap); Console.WriteLine("memory usage: " + andbitmap.SizeInBytes + " bytes"); EwahCompressedBitArray xorbitmap = ewahBitmap1.Xor(ewahBitmap2); Console.WriteLine("bitmap 1 XOR bitmap 2:" + xorbitmap); Console.WriteLine("memory usage: " + andbitmap.SizeInBytes + " bytes"); Console.WriteLine("End of demo."); Console.WriteLine(""); var tr = new EwahCompressedBitArrayTest(); tr.TestYnosa(); tr.TestIntersectOddNess(); tr.testsetSizeInBits(); tr.SsiYanKaiTest(); tr.testDebugSetSizeInBitsTest(); tr.EwahIteratorProblem(); tr.TayaraTest(); tr.TestNot(); tr.TestCardinality(); tr.TestEwahCompressedBitArray(); tr.TestExternalization(); tr.TestLargeEwahCompressedBitArray(); tr.TestMassiveAnd(); tr.TestMassiveAndNot(); tr.TestMassiveOr(); tr.TestMassiveXOR(); tr.HabermaasTest(); tr.VanSchaikTest(); tr.TestRunningLengthWord(); tr.TestSizeInBits1(); tr.TestHasNextSafe(); tr.TestCloneEwahCompressedBitArray(); tr.TestSetGet(); tr.TestWithParameters(); new EWAHCompressedBitArraySerializerTest().TestCustomSerializationStrategy(); }
public void SsiYanKaiTest() { Console.WriteLine("testing SsiYanKaiTest"); EwahCompressedBitArray a = EwahCompressedBitArray.BitmapOf(39935, 39936, 39937, 39938, 39939, 39940, 39941, 39942, 39943, 39944, 39945, 39946, 39947, 39948, 39949, 39950, 39951, 39952, 39953, 39954, 39955, 39956, 39957, 39958, 39959, 39960, 39961, 39962, 39963, 39964, 39965, 39966, 39967, 39968, 39969, 39970, 39971, 39972, 39973, 39974, 39975, 39976, 39977, 39978, 39979, 39980, 39981, 39982, 39983, 39984, 39985, 39986, 39987, 39988, 39989, 39990, 39991, 39992, 39993, 39994, 39995, 39996, 39997, 39998, 39999, 40000, 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, 40030, 40031, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039, 40040, 40041, 40042, 40043, 40044, 40045, 40046, 40047, 40048, 40049, 40050, 40051, 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059, 40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069, 40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, 40078, 40079, 40080, 40081, 40082, 40083, 40084, 40085, 40086, 40087, 40088, 40089, 40090, 40091, 40092, 40093, 40094, 40095, 40096, 40097, 40098, 40099, 40100); EwahCompressedBitArray b = EwahCompressedBitArray.BitmapOf(39935, 39936, 39937, 39938, 39939, 39940, 39941, 39942, 39943, 39944, 39945, 39946, 39947, 39948, 39949, 39950, 39951, 39952, 39953, 39954, 39955, 39956, 39957, 39958, 39959, 39960, 39961, 39962, 39963, 39964, 39965, 39966, 39967, 39968, 39969, 39970, 39971, 39972, 39973, 39974, 39975, 39976, 39977, 39978, 39979, 39980, 39981, 39982, 39983, 39984, 39985, 39986, 39987, 39988, 39989, 39990, 39991, 39992, 39993, 39994, 39995, 39996, 39997, 39998, 39999, 270000); HashSet <int> aPositions = new HashSet <int>(a.GetPositions()); int intersection = 0; EwahCompressedBitArray inter = new EwahCompressedBitArray(); HashSet <int> bPositions = new HashSet <int>(b.GetPositions()); foreach (int integer in bPositions) { if (aPositions.Contains(integer)) { inter.Set(integer); ++intersection; } } EwahCompressedBitArray and2 = a.And(b); List <int> l1 = inter.GetPositions(); List <int> l2 = and2.GetPositions(); var ok = true; if (l1.Count != l2.Count) { Console.WriteLine("cardinality differs = " + l1.Count + " " + l2.Count); ok = false; } for (int k = 0; k < l1.Count; ++k) { if (l1[k] != l2[k]) { Console.WriteLine("differ at " + k + " = " + l1[k] + " " + l2[k]); ok = false; } } Assert.IsTrue(ok); Assert.AreEqual(true, and2.Equals(inter)); Assert.AreEqual(inter.GetHashCode(), and2.GetHashCode()); Assert.AreEqual(intersection, and2.GetCardinality()); }