Package org.tinspin.index.critbit
Class BitTools
- java.lang.Object
-
- org.tinspin.index.critbit.BitTools
-
public class BitTools extends Object
- Author:
- Tilmann Zaeschke
-
-
Constructor Summary
Constructors Constructor Description BitTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleangetAndCopyBit(long[] src, int posBit, long[] dst)static booleangetBit(long[] ba, int posBit)static booleangetBit(long l, int posBit)static longmerge(long[] srcV, int src1, int src2, int nBits)Merges two long values into a single value by interleaving there respective bits.static long[]mergeLong(int nBitsPerValue, long[] src)Merges long values into a single value by interleaving there respective bits.static longreverse(long l, int usedBits)Reverses the value, considering that not all 64bits of the long value are used.static longset0(long ba, int posBit)static longset1(long ba, int posBit)static voidsetBit(long[] ba, int posBit, boolean b)static longsetBit(long ba, int posBit, boolean b)static voidsplit(long toSplit, long[] trgV, int trg1, int trg2, int nBits)Splits a value and write it to trgV at position trg1 and trg2.static long[]splitLong(int dims, int nBitsPerValue, long[] toSplit)Splits a value and write it to trgV at position trg1 and trg2.static StringtoBinary(long[] la, int DEPTH)static StringtoBinary(long l, int DEPTH)static doubletoDouble(long value)static double[]toDouble(long[] value, double[] ret)static floattoFloat(long value)static float[]toFloat(long[] value, float[] ret)static longtoSortableLong(double value)static long[]toSortableLong(double[] value, long[] ret)static longtoSortableLong(float value)static long[]toSortableLong(float[] value, long[] ret)static longtoSortableLong(String s)
-
-
-
Method Detail
-
toSortableLong
public static long toSortableLong(double value)
- Parameters:
value- value to convert- Returns:
- long representation.
-
toSortableLong
public static long toSortableLong(float value)
-
toDouble
public static double toDouble(long value)
-
toFloat
public static float toFloat(long value)
-
toSortableLong
public static long[] toSortableLong(double[] value, long[] ret)- Parameters:
value- Value to be transformedret- The array used to store the return value- Returns:
- long representation.
-
toSortableLong
public static long[] toSortableLong(float[] value, long[] ret)
-
toDouble
public static double[] toDouble(long[] value, double[] ret)
-
toFloat
public static float[] toFloat(long[] value, float[] ret)
-
toSortableLong
public static long toSortableLong(String s)
-
reverse
public static long reverse(long l, int usedBits)Reverses the value, considering that not all 64bits of the long value are used.- Parameters:
l- value to be reversedusedBits- Number of bits to be considered- Returns:
- Reversed value
-
split
public static void split(long toSplit, long[] trgV, int trg1, int trg2, int nBits)Splits a value and write it to trgV at position trg1 and trg2. This is the inverse operation to merge(...).- Parameters:
toSplit- value to splittrgV- return valuetrg1- return position part 1trg2- return position part 2nBits- Number of bits of source value
-
merge
public static long merge(long[] srcV, int src1, int src2, int nBits)Merges two long values into a single value by interleaving there respective bits. This is the inverse operation to split(...).- Parameters:
srcV- Source arraysrc1- Position of 1st source valuesrc2- Position of 2nd source valuenBits- Number of bits of RESULT- Returns:
- Merged result
-
mergeLong
public static long[] mergeLong(int nBitsPerValue, long[] src)Merges long values into a single value by interleaving there respective bits. This is the inverse operation to split(...).- Parameters:
src- Source arraynBitsPerValue- Number of bits of each source value- Returns:
- Merged result
-
splitLong
public static long[] splitLong(int dims, int nBitsPerValue, long[] toSplit)Splits a value and write it to trgV at position trg1 and trg2. This is the inverse operation to merge(...).- Parameters:
dims- number of splinters to split intotoSplit- value to splitnBitsPerValue- Number of bits of source value- Returns:
- long[] with 'dims' entries
-
getBit
public static boolean getBit(long[] ba, int posBit)- Parameters:
ba- byte arrayposBit- Counts from left to right!!!- Returns:
- current bit
-
getBit
public static boolean getBit(long l, int posBit)- Parameters:
l- bit setposBit- Counts from left to right!!!- Returns:
- current bit
-
getAndCopyBit
public static boolean getAndCopyBit(long[] src, int posBit, long[] dst)- Parameters:
src- source array Reads a bit fromsrc, writes it todstand returns it.posBit- Counts from left to rightdst- target array- Returns:
- current bit
-
setBit
public static void setBit(long[] ba, int posBit, boolean b)- Parameters:
ba- byte arrayposBit- Counts from left to right (highest to lowest)!!!b- bit to set
-
setBit
public static long setBit(long ba, int posBit, boolean b)
-
set1
public static long set1(long ba, int posBit)
-
set0
public static long set0(long ba, int posBit)
-
toBinary
public static String toBinary(long[] la, int DEPTH)
-
toBinary
public static String toBinary(long l, int DEPTH)
-
-