java.lang.Object
org.bitlap.roaringbitmap.Util
Various useful methods for roaring bitmaps.
-
字段概要
字段修饰符和类型字段说明static final booleanoptimization flag: whether to use hybrid binary search: hybrid formats combine a binary search with a sequential search -
方法概要
修饰符和类型方法说明static Container[]Add value "offset" to all values in the container, producing two new containers.static intadvanceUntil(char[] array, int pos, int length, char min) Find the smallest integer larger than pos such that array[pos]>= min.protected static intbranchyUnsignedBinarySearch(char[] array, int begin, int end, char k) static intcardinalityInBitmapRange(long[] bitmap, int start, int end) Hamming weight of the bitset in the range start, start+1,..., end-1static intcardinalityInBitmapWordRange(long[] bitmap, int start, int end) 已过时。static voidfillArrayAND(char[] container, long[] bitmap1, long[] bitmap2) Compute the bitwise AND between two long arrays and write the set bits in the container.static voidfillArrayANDNOT(char[] container, long[] bitmap1, long[] bitmap2) Compute the bitwise ANDNOT between two long arrays and write the set bits in the container.static voidfillArrayXOR(char[] container, long[] bitmap1, long[] bitmap2) Compute the bitwise XOR between two long arrays and write the set bits in the container.static voidflipBitmapRange(long[] bitmap, int start, int end) flip bits at start, start+1,..., end-1static intflipBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end) 已过时。protected static charhighbits(int x) protected static charhighbits(long x) protected static inthybridUnsignedBinarySearch(char[] array, int begin, int end, char k) static intintersectArrayIntoBitmap(long[] bitmap, char[] array, int length) Intersects the bitmap with the array, returning the cardinality of the resultstatic intiterateUntil(char[] array, int pos, int length, int min) Find the smallest integer larger than pos such that array[pos]>= min.protected static charlowbits(int x) protected static charlowbits(long x) protected static intlowbitsAsInteger(int x) protected static intlowbitsAsInteger(long x) static intstatic voidpartialRadixSort(int[] data) Sorts the data by the 16 bit prefix using Radix sort.static voidresetBitmapRange(long[] bitmap, int start, int end) clear bits at start, start+1,..., end-1static intresetBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end) 已过时。static intreverseUntil(char[] array, int pos, int length, char max) Find the largest integer smaller than pos such that array[pos]<= max.static intselect(long w, int j) Given a word w, return the position of the jth true bit.static voidsetBitmapRange(long[] bitmap, int start, int end) set bits at start, start+1,..., end-1static intsetBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end) 已过时。static longtoUnsignedLong(int x) Converts the argument to alongby an unsigned conversion.static intunsignedBinarySearch(char[] array, int begin, int end, char k) Look for value k in array in the range [begin,end).static intunsignedDifference(char[] set1, int length1, char[] set2, int length2, char[] buffer) Compute the difference between two sorted lists and write the result to the provided output arraystatic intunsignedDifference(CharIterator set1, CharIterator set2, char[] buffer) Compute the difference between two sorted lists and write the result to the provided output arraystatic intunsignedExclusiveUnion2by2(char[] set1, int length1, char[] set2, int length2, char[] buffer) Compute the exclusive union of two sorted lists and write the result to the provided output arraystatic intunsignedIntersect2by2(char[] set1, int length1, char[] set2, int length2, char[] buffer) Intersect two sorted lists and write the result to the provided output arraystatic booleanunsignedIntersects(char[] set1, int length1, char[] set2, int length2) Checks if two arrays intersectprotected static intunsignedLocalIntersect2by2(char[] set1, int length1, char[] set2, int length2, char[] buffer) static intunsignedLocalIntersect2by2Cardinality(char[] set1, int length1, char[] set2, int length2) Compute the cardinality of the intersectionprotected static intunsignedOneSidedGallopingIntersect2by2(char[] smallSet, int smallLength, char[] largeSet, int largeLength, char[] buffer) static intunsignedUnion2by2(char[] set1, int offset1, int length1, char[] set2, int offset2, int length2, char[] buffer) Unite two sorted lists and write the result to the provided output array
-
字段详细资料
-
USE_HYBRID_BINSEARCH
public static final boolean USE_HYBRID_BINSEARCHoptimization flag: whether to use hybrid binary search: hybrid formats combine a binary search with a sequential search- 另请参阅:
-
-
方法详细资料
-
addOffset
Add value "offset" to all values in the container, producing two new containers. The existing container remains unchanged. The new container are not converted, so they need to be checked: e.g., we could produce two bitmap containers having low cardinality.- 参数:
source- source containeroffsets- value to add to each value in the container- 返回:
- return an array made of two containers
-
advanceUntil
public static int advanceUntil(char[] array, int pos, int length, char min) Find the smallest integer larger than pos such that array[pos]>= min. If none can be found, return length. Based on code by O. Kaser.- 参数:
array- array to search withinpos- starting position of the searchlength- length of the array to searchmin- minimum value- 返回:
- x greater than pos such that array[pos] is at least as large as min, pos is is equal to length if it is not possible.
-
reverseUntil
public static int reverseUntil(char[] array, int pos, int length, char max) Find the largest integer smaller than pos such that array[pos]<= max. If none can be found, return length. Based on code by O. Kaser.- 参数:
array- array to search withinpos- starting position of the searchlength- length of the array to searchmax- maximum value- 返回:
- x less than pos such that array[pos] is at least as small as max, pos is is equal to 0 if it is not possible.
-
iterateUntil
public static int iterateUntil(char[] array, int pos, int length, int min) Find the smallest integer larger than pos such that array[pos]>= min. If none can be found, return length.- 参数:
array- array to search withinpos- starting position of the searchlength- length of the array to searchmin- minimum value- 返回:
- x greater than pos such that array[pos] is at least as large as min, pos is is equal to length if it is not possible.
-
branchyUnsignedBinarySearch
protected static int branchyUnsignedBinarySearch(char[] array, int begin, int end, char k) -
fillArrayAND
public static void fillArrayAND(char[] container, long[] bitmap1, long[] bitmap2) Compute the bitwise AND between two long arrays and write the set bits in the container.- 参数:
container- where we writebitmap1- first bitmapbitmap2- second bitmap
-
fillArrayANDNOT
public static void fillArrayANDNOT(char[] container, long[] bitmap1, long[] bitmap2) Compute the bitwise ANDNOT between two long arrays and write the set bits in the container.- 参数:
container- where we writebitmap1- first bitmapbitmap2- second bitmap
-
fillArrayXOR
public static void fillArrayXOR(char[] container, long[] bitmap1, long[] bitmap2) Compute the bitwise XOR between two long arrays and write the set bits in the container.- 参数:
container- where we writebitmap1- first bitmapbitmap2- second bitmap
-
flipBitmapRange
public static void flipBitmapRange(long[] bitmap, int start, int end) flip bits at start, start+1,..., end-1- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)
-
cardinalityInBitmapWordRange
已过时。Hamming weight of the 64-bit words involved in the range start, start+1,..., end-1, that is, it will compute the cardinality of the bitset from index (floor(start/64) to floor((end-1)/64)) inclusively.- 参数:
bitmap- array of words representing a bitsetstart- first index (inclusive)end- last index (exclusive)- 返回:
- the hamming weight of the corresponding words
-
cardinalityInBitmapRange
public static int cardinalityInBitmapRange(long[] bitmap, int start, int end) Hamming weight of the bitset in the range start, start+1,..., end-1- 参数:
bitmap- array of words representing a bitsetstart- first index (inclusive)end- last index (exclusive)- 返回:
- the hamming weight of the corresponding range
-
highbits
protected static char highbits(int x) -
highbits
protected static char highbits(long x) -
hybridUnsignedBinarySearch
protected static int hybridUnsignedBinarySearch(char[] array, int begin, int end, char k) -
lowbits
protected static char lowbits(int x) -
lowbits
protected static char lowbits(long x) -
lowbitsAsInteger
protected static int lowbitsAsInteger(int x) -
lowbitsAsInteger
protected static int lowbitsAsInteger(long x) -
maxLowBitAsInteger
public static int maxLowBitAsInteger() -
resetBitmapRange
public static void resetBitmapRange(long[] bitmap, int start, int end) clear bits at start, start+1,..., end-1- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)
-
intersectArrayIntoBitmap
public static int intersectArrayIntoBitmap(long[] bitmap, char[] array, int length) Intersects the bitmap with the array, returning the cardinality of the result- 参数:
bitmap- the bitmap, modifiedarray- the array, not modifiedlength- how much of the array to consume- 返回:
- the size of the intersection, i.e. how many bits still set in the bitmap
-
select
public static int select(long w, int j) Given a word w, return the position of the jth true bit.- 参数:
w- wordj- index- 返回:
- position of jth true bit in w
-
setBitmapRange
public static void setBitmapRange(long[] bitmap, int start, int end) set bits at start, start+1,..., end-1- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)
-
setBitmapRangeAndCardinalityChange
已过时。set bits at start, start+1,..., end-1 and report the cardinality change- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)- 返回:
- cardinality change
-
flipBitmapRangeAndCardinalityChange
@Deprecated public static int flipBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end) 已过时。flip bits at start, start+1,..., end-1 and report the cardinality change- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)- 返回:
- cardinality change
-
resetBitmapRangeAndCardinalityChange
@Deprecated public static int resetBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end) 已过时。reset bits at start, start+1,..., end-1 and report the cardinality change- 参数:
bitmap- array of words to be modifiedstart- first index to be modified (inclusive)end- last index to be modified (exclusive)- 返回:
- cardinality change
-
unsignedBinarySearch
public static int unsignedBinarySearch(char[] array, int begin, int end, char k) Look for value k in array in the range [begin,end). If the value is found, return its index. If not, return -(i+1) where i is the index where the value would be inserted. The array is assumed to contain sorted values where shorts are interpreted as unsigned integers.- 参数:
array- array where we searchbegin- first index (inclusive)end- last index (exclusive)k- value we search for- 返回:
- count
-
unsignedDifference
public static int unsignedDifference(char[] set1, int length1, char[] set2, int length2, char[] buffer) Compute the difference between two sorted lists and write the result to the provided output array- 参数:
set1- first arraylength1- length of first arrayset2- second arraylength2- length of second arraybuffer- output array- 返回:
- cardinality of the difference
-
unsignedDifference
Compute the difference between two sorted lists and write the result to the provided output array- 参数:
set1- first arrayset2- second arraybuffer- output array- 返回:
- cardinality of the difference
-
unsignedExclusiveUnion2by2
public static int unsignedExclusiveUnion2by2(char[] set1, int length1, char[] set2, int length2, char[] buffer) Compute the exclusive union of two sorted lists and write the result to the provided output array- 参数:
set1- first arraylength1- length of first arrayset2- second arraylength2- length of second arraybuffer- output array- 返回:
- cardinality of the exclusive union
-
unsignedIntersect2by2
public static int unsignedIntersect2by2(char[] set1, int length1, char[] set2, int length2, char[] buffer) Intersect two sorted lists and write the result to the provided output array- 参数:
set1- first arraylength1- length of first arrayset2- second arraylength2- length of second arraybuffer- output array- 返回:
- cardinality of the intersection
-
unsignedIntersects
public static boolean unsignedIntersects(char[] set1, int length1, char[] set2, int length2) Checks if two arrays intersect- 参数:
set1- first arraylength1- length of first arrayset2- second arraylength2- length of second array- 返回:
- true if they intersect
-
unsignedLocalIntersect2by2
protected static int unsignedLocalIntersect2by2(char[] set1, int length1, char[] set2, int length2, char[] buffer) -
unsignedLocalIntersect2by2Cardinality
public static int unsignedLocalIntersect2by2Cardinality(char[] set1, int length1, char[] set2, int length2) Compute the cardinality of the intersection- 参数:
set1- first setlength1- how many values to consider in the first setset2- second setlength2- how many values to consider in the second set- 返回:
- cardinality of the intersection
-
unsignedOneSidedGallopingIntersect2by2
protected static int unsignedOneSidedGallopingIntersect2by2(char[] smallSet, int smallLength, char[] largeSet, int largeLength, char[] buffer) -
unsignedUnion2by2
public static int unsignedUnion2by2(char[] set1, int offset1, int length1, char[] set2, int offset2, int length2, char[] buffer) Unite two sorted lists and write the result to the provided output array- 参数:
set1- first arrayoffset1- offset of first arraylength1- length of first arrayset2- second arrayoffset2- offset of second arraylength2- length of second arraybuffer- output array- 返回:
- cardinality of the union
-
toUnsignedLong
public static long toUnsignedLong(int x) Converts the argument to alongby an unsigned conversion. In an unsigned conversion to along, the high-order 32 bits of thelongare zero and the low-order 32 bits are equal to the bits of the integer argument. Consequently, zero and positiveintvalues are mapped to a numerically equallongvalue and negativeintvalues are mapped to alongvalue equal to the input plus 232.- 参数:
x- the value to convert to an unsignedlong- 返回:
- the argument converted to
longby an unsigned conversion - 从以下版本开始:
- 1.8
-
partialRadixSort
public static void partialRadixSort(int[] data) Sorts the data by the 16 bit prefix using Radix sort. The resulting data will be partially sorted if you just take into account the most significant 16 bits. The least significant 16 bits are unsorted. Note that we treat int values as unsigned integers (from 0 to 2^32).- 参数:
data- - the data (sorted in place)
-