Java BitSet decodeIndex(final BitSet bs, final long rangePerDimension)

Here you can find the source of decodeIndex(final BitSet bs, final long rangePerDimension)

Description

decode Index

License

Apache License

Declaration

private static long decodeIndex(final BitSet bs,
            final long rangePerDimension) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.BitSet;

public class Main {
    private static long decodeIndex(final BitSet bs,
            final long rangePerDimension) {
        long floor = 0;
        long ceiling = rangePerDimension;
        long mid = 0;
        for (int i = 0; i < bs.length(); i++) {
            mid = (floor + ceiling) / 2;
            if (bs.get(i)) {
                floor = mid;/*from   w w  w  .  j a v  a2  s  .  co  m*/
            } else {
                ceiling = mid;
            }
        }
        return mid;
    }
}

Related

  1. copyBitSetToBitSet(BitSet src, int srcPos, BitSet dest, int destPos, int length)
  2. countLeadingSimilarBits(BitSet a, BitSet b)
  3. createBitSetFromBinaryString(String bitsAsBinaryString)
  4. createSimpleBitSet(Set setBits)
  5. decode(BitSet encoded, int encodedBitLength)
  6. deleteBits(BitSet bs, BitSet bsDelete)
  7. dualNext(BitSet b)
  8. encode(BitSet allowedCharacters, String s, String charset)
  9. encode(BitSet origin, int originBitLength)