How to use RoaringBitmap
This article mainly introduces "the use of RoaringBitmap". In the daily operation, I believe that many people have doubts about the use of RoaringBitmap. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about the use of RoaringBitmap. Next, please follow the editor to study!
1. Simple Demo
Reference: RoaringBitmap
Public class Demo {@ Test public void test1 () {/ / add four digits 1, 2, 3, 1000 to R1 RoaringBitmap R1 = RoaringBitmap.bitmapOf (1, 2, 3, 1000); / / return the third number is 1000 System.out.println (r1.select (3)); r1.add (5) / / returns an index of 10000, which is 4 System.out.println (r1.rank (1000)); System.out.println (r1.rank (3)); System.out.println (r1.rank (2)); System.out.println (r1.rank (1)); / / whether it contains 1000 and 7 false System.out.println (r1.contains (1000)) System.out.println (r1.contains (7)); RoaringBitmap R2 = new RoaringBitmap (); / / add 2000 digital r2.add (10000L, 12000L) of 10000-12000 to R2; / / merge the two R1 r2.add R2, merge the values, and merge to produce a new RoaringBitmap RoaringBitmap R3 = RoaringBitmap.or (R2). / / R1 and R2 perform bit operations and assign the result to R1 r1.or (R2); / / determine whether R1 and R3 are equal, true System.out.println (r1.equals (R3)); / / see how many values are stored in R1, 2004 System.out.println (r1.getLongCardinality ()) / / two traversal methods for (int I: R1) {System.out.println (I);} r1.forEach ((Consumer)