public final class Util extends Object
Modifier and Type | Field and Description |
---|---|
static boolean |
USE_HYBRID_BINSEARCH
optimization flag: whether to use hybrid binary search: hybrid formats
combine a binary search with a sequential search
|
Modifier and Type | Method and Description |
---|---|
static int |
advanceUntil(short[] array,
int pos,
int length,
short min)
Find the smallest integer larger than pos such that array[pos]>= min.
|
protected static int |
branchyUnsignedBinarySearch(short[] array,
int begin,
int end,
short k) |
static int |
cardinalityInBitmapRange(long[] bitmap,
int start,
int end)
Hamming weight of the bitset in the range
start, start+1,..., end-1
|
static int |
cardinalityInBitmapWordRange(long[] bitmap,
int start,
int end)
Deprecated.
|
static int |
compareUnsigned(short a,
short b)
Compares the two specified
short values, treating them as unsigned values between
0 and 2^16 - 1 inclusive. |
static void |
fillArrayAND(short[] container,
long[] bitmap1,
long[] bitmap2)
Compute the bitwise AND between two long arrays and write the set bits in the container.
|
static void |
fillArrayANDNOT(short[] container,
long[] bitmap1,
long[] bitmap2)
Compute the bitwise ANDNOT between two long arrays and write the set bits in the container.
|
static void |
fillArrayXOR(short[] container,
long[] bitmap1,
long[] bitmap2)
Compute the bitwise XOR between two long arrays and write the set bits in the container.
|
static void |
flipBitmapRange(long[] bitmap,
int start,
int end)
flip bits at start, start+1,..., end-1
|
static int |
flipBitmapRangeAndCardinalityChange(long[] bitmap,
int start,
int end)
Deprecated.
|
protected static short |
highbits(int x) |
protected static short |
highbits(long x) |
protected static int |
hybridUnsignedBinarySearch(short[] array,
int begin,
int end,
short k) |
protected static short |
lowbits(int x) |
protected static short |
lowbits(long x) |
protected static short |
maxLowBit() |
protected static int |
maxLowBitAsInteger() |
static void |
partialRadixSort(int[] data)
Sorts the data by the 16 bit prefix.
|
static void |
resetBitmapRange(long[] bitmap,
int start,
int end)
clear bits at start, start+1,..., end-1
|
static int |
resetBitmapRangeAndCardinalityChange(long[] bitmap,
int start,
int end)
Deprecated.
|
static int |
select(long w,
int j)
Given a word w, return the position of the jth true bit.
|
static void |
setBitmapRange(long[] bitmap,
int start,
int end)
set bits at start, start+1,..., end-1
|
static int |
setBitmapRangeAndCardinalityChange(long[] bitmap,
int start,
int end)
Deprecated.
|
protected static int |
toIntUnsigned(short x) |
static long |
toUnsignedLong(int x)
Converts the argument to a
long by an unsigned conversion. |
static int |
unsignedBinarySearch(short[] array,
int begin,
int end,
short k)
Look for value k in array in the range [begin,end).
|
static int |
unsignedDifference(short[] set1,
int length1,
short[] set2,
int length2,
short[] buffer)
Compute the difference between two sorted lists and write the result to the provided output
array
|
static int |
unsignedDifference(ShortIterator set1,
ShortIterator set2,
short[] buffer)
Compute the difference between two sorted lists and write the result to the provided output
array
|
static int |
unsignedExclusiveUnion2by2(short[] set1,
int length1,
short[] set2,
int length2,
short[] buffer)
Compute the exclusive union of two sorted lists and write the result to the provided output
array
|
static int |
unsignedIntersect2by2(short[] set1,
int length1,
short[] set2,
int length2,
short[] buffer)
Intersect two sorted lists and write the result to the provided output array
|
static boolean |
unsignedIntersects(short[] set1,
int length1,
short[] set2,
int length2)
Checks if two arrays intersect
|
protected static int |
unsignedLocalIntersect2by2(short[] set1,
int length1,
short[] set2,
int length2,
short[] buffer) |
static int |
unsignedLocalIntersect2by2Cardinality(short[] set1,
int length1,
short[] set2,
int length2)
Compute the cardinality of the intersection
|
protected static int |
unsignedOneSidedGallopingIntersect2by2(short[] smallSet,
int smallLength,
short[] largeSet,
int largeLength,
short[] buffer) |
static int |
unsignedUnion2by2(short[] set1,
int offset1,
int length1,
short[] set2,
int offset2,
int length2,
short[] buffer)
Unite two sorted lists and write the result to the provided output array
|
public static final boolean USE_HYBRID_BINSEARCH
public static int advanceUntil(short[] array, int pos, int length, short min)
array
- array to search withinpos
- starting position of the searchlength
- length of the array to searchmin
- minimum valueprotected static int branchyUnsignedBinarySearch(short[] array, int begin, int end, short k)
public static int compareUnsigned(short a, short b)
short
values, treating them as unsigned values between
0
and 2^16 - 1
inclusive.a
- the first unsigned short
to compareb
- the second unsigned short
to comparea
is less than b
; a positive value if a
is
greater than b
; or zero if they are equalpublic static void fillArrayAND(short[] container, long[] bitmap1, long[] bitmap2)
container
- where we writebitmap1
- first bitmapbitmap2
- second bitmappublic static void fillArrayANDNOT(short[] container, long[] bitmap1, long[] bitmap2)
container
- where we writebitmap1
- first bitmapbitmap2
- second bitmappublic static void fillArrayXOR(short[] container, long[] bitmap1, long[] bitmap2)
container
- where we writebitmap1
- first bitmapbitmap2
- second bitmappublic static void flipBitmapRange(long[] bitmap, int start, int end)
bitmap
- array of words to be modifiedstart
- first index to be modified (inclusive)end
- last index to be modified (exclusive)@Deprecated public static int cardinalityInBitmapWordRange(long[] bitmap, int start, int end)
bitmap
- array of words representing a bitsetstart
- first index (inclusive)end
- last index (exclusive)public static int cardinalityInBitmapRange(long[] bitmap, int start, int end)
bitmap
- array of words representing a bitsetstart
- first index (inclusive)end
- last index (exclusive)protected static short highbits(int x)
protected static short highbits(long x)
protected static int hybridUnsignedBinarySearch(short[] array, int begin, int end, short k)
protected static short lowbits(int x)
protected static short lowbits(long x)
protected static short maxLowBit()
protected static int maxLowBitAsInteger()
public static void resetBitmapRange(long[] bitmap, int start, int end)
bitmap
- array of words to be modifiedstart
- first index to be modified (inclusive)end
- last index to be modified (exclusive)public static int select(long w, int j)
w
- wordj
- indexpublic static void setBitmapRange(long[] bitmap, int start, int end)
bitmap
- array of words to be modifiedstart
- first index to be modified (inclusive)end
- last index to be modified (exclusive)@Deprecated public static int setBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end)
bitmap
- array of words to be modifiedstart
- first index to be modified (inclusive)end
- last index to be modified (exclusive)@Deprecated public static int flipBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end)
bitmap
- array of words to be modifiedstart
- first index to be modified (inclusive)end
- last index to be modified (exclusive)@Deprecated public static int resetBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end)
bitmap
- array of words to be modifiedstart
- first index to be modified (inclusive)end
- last index to be modified (exclusive)protected static int toIntUnsigned(short x)
public static int unsignedBinarySearch(short[] array, int begin, int end, short k)
array
- array where we searchbegin
- first index (inclusive)end
- last index (exclusive)k
- value we search forpublic static int unsignedDifference(short[] set1, int length1, short[] set2, int length2, short[] buffer)
set1
- first arraylength1
- length of first arrayset2
- second arraylength2
- length of second arraybuffer
- output arraypublic static int unsignedDifference(ShortIterator set1, ShortIterator set2, short[] buffer)
set1
- first arrayset2
- second arraybuffer
- output arraypublic static int unsignedExclusiveUnion2by2(short[] set1, int length1, short[] set2, int length2, short[] buffer)
set1
- first arraylength1
- length of first arrayset2
- second arraylength2
- length of second arraybuffer
- output arraypublic static int unsignedIntersect2by2(short[] set1, int length1, short[] set2, int length2, short[] buffer)
set1
- first arraylength1
- length of first arrayset2
- second arraylength2
- length of second arraybuffer
- output arraypublic static boolean unsignedIntersects(short[] set1, int length1, short[] set2, int length2)
set1
- first arraylength1
- length of first arrayset2
- second arraylength2
- length of second arrayprotected static int unsignedLocalIntersect2by2(short[] set1, int length1, short[] set2, int length2, short[] buffer)
public static int unsignedLocalIntersect2by2Cardinality(short[] set1, int length1, short[] set2, int length2)
set1
- first setlength1
- how many values to consider in the first setset2
- second setlength2
- how many values to consider in the second setprotected static int unsignedOneSidedGallopingIntersect2by2(short[] smallSet, int smallLength, short[] largeSet, int largeLength, short[] buffer)
public static int unsignedUnion2by2(short[] set1, int offset1, int length1, short[] set2, int offset2, int length2, short[] buffer)
set1
- first arrayoffset1
- offset of first arraylength1
- length of first arrayset2
- second arrayoffset2
- offset of second arraylength2
- length of second arraybuffer
- output arraypublic static long toUnsignedLong(int x)
long
by an unsigned conversion. In an unsigned conversion to
a long
, the high-order 32 bits of the long
are zero and the low-order 32 bits
are equal to the bits of the integer argument.
Consequently, zero and positive int
values are mapped to a numerically equal
long
value and negative int
values are mapped to a long
value equal to the input plus 232.x
- the value to convert to an unsigned long
long
by an unsigned conversionpublic static void partialRadixSort(int[] data)
data
- - the dataCopyright © 2018. All rights reserved.