// Path: src/io/lacuna/bifurcan/utils/Bits.java
// public static int bitOffset(long n) {
//   return deBruijnIndex[0xFF & (int) ((n * 0x022fdd63cc95386dL) >>> 58)];
// }
// 
// Path: src/io/lacuna/bifurcan/utils/Bits.java
// public static long highestBit(long n) {
//   return Long.highestOneBit(n);
// }
// 
// Path: src/io/lacuna/bifurcan/utils/Bits.java
// public static long lowestBit(long n) {
//   return n & -n;
// }


import java.util.NoSuchElementException;
import java.util.PrimitiveIterator;
import static io.lacuna.bifurcan.utils.Bits.bitOffset;
import static io.lacuna.bifurcan.utils.Bits.highestBit;
import static io.lacuna.bifurcan.utils.Bits.lowestBit;
import static java.lang.Integer.bitCount;
package io.lacuna.bifurcan.nodes;



/**
 * @author ztellman
 */
public class Util {

  static final Object DEFAULT_VALUE = new Object();

  static final int NONE_NONE = 0;
  static final int NODE_NONE = 0x1;
  static final int ENTRY_NONE = 0x2;
  static final int NONE_NODE = 0x4;
  static final int NONE_ENTRY = 0x8;
  static final int ENTRY_NODE = ENTRY_NONE | NONE_NODE;
  static final int NODE_ENTRY = NODE_NONE | NONE_ENTRY;
  static final int ENTRY_ENTRY = ENTRY_NONE | NONE_ENTRY;
  static final int NODE_NODE = NODE_NONE | NONE_NODE;

  public static int mergeState(int mask, int nodeA, int dataA, int nodeB, int dataB) {
    int state = 0;

    // this compiles down to no branches, apparently
    state |= ((mask & nodeA) != 0 ? 1 : 0);
    state |= ((mask & dataA) != 0 ? 1 : 0) << 1;
    state |= ((mask & nodeB) != 0 ? 1 : 0) << 2;
    state |= ((mask & dataB) != 0 ? 1 : 0) << 3;

    return state;
  }

  static int compressedIndex(int bitmap, int hashMask) {
    return bitCount(bitmap & (hashMask - 1));
  }

  public static int startIndex(int bitmap) {
    return bitOffset(lowestBit(bitmap & 0xFFFFFFFFL));
  }

  public static int endIndex(int bitmap) {
// Path: src/io/lacuna/bifurcan/utils/Bits.java
// public static int bitOffset(long n) {
//   return deBruijnIndex[0xFF & (int) ((n * 0x022fdd63cc95386dL) >>> 58)];
// }
// 
// Path: src/io/lacuna/bifurcan/utils/Bits.java
// public static long highestBit(long n) {
//   return Long.highestOneBit(n);
// }
// 
// Path: src/io/lacuna/bifurcan/utils/Bits.java
// public static long lowestBit(long n) {
//   return n & -n;
// }


// Path: src/io/lacuna/bifurcan/nodes/Util.java
import java.util.NoSuchElementException;
import java.util.PrimitiveIterator;
import static io.lacuna.bifurcan.utils.Bits.bitOffset;
import static io.lacuna.bifurcan.utils.Bits.highestBit;
import static io.lacuna.bifurcan.utils.Bits.lowestBit;
import static java.lang.Integer.bitCount;

package io.lacuna.bifurcan.nodes;



/**
 * @author ztellman
 */
public class Util {

  static final Object DEFAULT_VALUE = new Object();

  static final int NONE_NONE = 0;
  static final int NODE_NONE = 0x1;
  static final int ENTRY_NONE = 0x2;
  static final int NONE_NODE = 0x4;
  static final int NONE_ENTRY = 0x8;
  static final int ENTRY_NODE = ENTRY_NONE | NONE_NODE;
  static final int NODE_ENTRY = NODE_NONE | NONE_ENTRY;
  static final int ENTRY_ENTRY = ENTRY_NONE | NONE_ENTRY;
  static final int NODE_NODE = NODE_NONE | NONE_NODE;

  public static int mergeState(int mask, int nodeA, int dataA, int nodeB, int dataB) {
    int state = 0;

    // this compiles down to no branches, apparently
    state |= ((mask & nodeA) != 0 ? 1 : 0);
    state |= ((mask & dataA) != 0 ? 1 : 0) << 1;
    state |= ((mask & nodeB) != 0 ? 1 : 0) << 2;
    state |= ((mask & dataB) != 0 ? 1 : 0) << 3;

    return state;
  }

  static int compressedIndex(int bitmap, int hashMask) {
    return bitCount(bitmap & (hashMask - 1));
  }

  public static int startIndex(int bitmap) {
    return bitOffset(lowestBit(bitmap & 0xFFFFFFFFL));
  }

  public static int endIndex(int bitmap) {
    return bitOffset(highestBit(bitmap & 0xFFFFFFFFL));