Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use RoaringBitmap

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report