Class BitUtil

java.lang.Object
com.carrotsearch.hppc.BitUtil

final class BitUtil extends Object
A variety of high efficiency bit twiddling routines.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    returns the next highest power of two, or the current value if it's already a power of two or zero
    static long
    returns the next highest power of two, or the current value if it's already a power of two or zero
    static long
    pop_andnot(long[] arr1, long[] arr2, int wordOffset, int numWords)
    Returns the popcount or cardinality of A invalid input: '&' ~B.
    static long
    pop_array(long[] arr, int wordOffset, int numWords)
    Returns the number of set bits in an array of longs.
    static long
    pop_intersect(long[] arr1, long[] arr2, int wordOffset, int numWords)
    Returns the popcount or cardinality of the two sets after an intersection.
    static long
    pop_union(long[] arr1, long[] arr2, int wordOffset, int numWords)
    Returns the popcount or cardinality of the union of two sets.
    static long
    pop_xor(long[] arr1, long[] arr2, int wordOffset, int numWords)
    Returns the popcount or cardinality of A ^ B Neither array is modified.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BitUtil

      private BitUtil()
  • Method Details

    • pop_array

      public static long pop_array(long[] arr, int wordOffset, int numWords)
      Returns the number of set bits in an array of longs.
    • pop_intersect

      public static long pop_intersect(long[] arr1, long[] arr2, int wordOffset, int numWords)
      Returns the popcount or cardinality of the two sets after an intersection. Neither array is modified.
    • pop_union

      public static long pop_union(long[] arr1, long[] arr2, int wordOffset, int numWords)
      Returns the popcount or cardinality of the union of two sets. Neither array is modified.
    • pop_andnot

      public static long pop_andnot(long[] arr1, long[] arr2, int wordOffset, int numWords)
      Returns the popcount or cardinality of A invalid input: '&' ~B. Neither array is modified.
    • pop_xor

      public static long pop_xor(long[] arr1, long[] arr2, int wordOffset, int numWords)
      Returns the popcount or cardinality of A ^ B Neither array is modified.
    • nextHighestPowerOfTwo

      public static int nextHighestPowerOfTwo(int v)
      returns the next highest power of two, or the current value if it's already a power of two or zero
    • nextHighestPowerOfTwo

      public static long nextHighestPowerOfTwo(long v)
      returns the next highest power of two, or the current value if it's already a power of two or zero