public final class BinaryUtils extends Object
Modifier and Type | Method and Description |
---|---|
static long |
allOnes(long length)
Returns a value with all bits set to 1 of length
length . |
static long |
fromBitSet(BitSet bits)
Converts the
BitSet bits into a long value. |
static long[] |
getAllPermutations(int bits,
int length)
Returns an array containing all permutations of a defined bitset with
bits set and
maximum length of length . |
static int[] |
getBitsSet(long val)
Returns the number of bits set.
|
static int |
getHammingDistance(long val1,
long val2)
Calculates the hamming distance between the two given values.
|
static boolean |
isBitSet(long val,
int pos)
Determines if the bit at position
pos in the value val is set. |
static long |
nextPermutation(long val)
Compute the lexicographically next bit permutation.
|
static BitSet |
toBitSet(int size,
long value)
|
public static final BitSet toBitSet(int size, long value)
public static final long fromBitSet(BitSet bits)
public static final long nextPermutation(long val)
public static final long[] getAllPermutations(int bits, int length)
bits
set and
maximum length of length
.public static final int getHammingDistance(long val1, long val2)
public static final long allOnes(long length)
length
.public static final boolean isBitSet(long val, int pos)
pos
in the value val
is set.public static final int[] getBitsSet(long val)
Copyright © 2012–2015 Christian Sterzl. All rights reserved.