Java BitSet decode(BitSet encoded, int encodedBitLength)

Here you can find the source of decode(BitSet encoded, int encodedBitLength)

Description

decode

License

Open Source License

Declaration

private static BitSet decode(BitSet encoded, int encodedBitLength) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.BitSet;

public class Main {
    private static BitSet decode(BitSet encoded, int encodedBitLength) {
        int decodedBitLength = encodedBitLength
                - (int) (Math.log(encodedBitLength) / Math.log(2)) - 1;
        BitSet decoded = new BitSet(decodedBitLength);

        for (int i = encodedBitLength - 1, j = decodedBitLength - 1; i >= 0; --i) {
            if (Math.log(encodedBitLength - i) / Math.log(2) % 1 != 0) {
                decoded.set(j, encoded.get(i));
                --j;/*from  ww  w  . j av a 2 s  .  co  m*/
            }
        }

        return decoded;
    }
}

Related

  1. copyBits(BitSet source, BitSet dest, int fromIndex)
  2. copyBitSetToBitSet(BitSet src, int srcPos, BitSet dest, int destPos, int length)
  3. countLeadingSimilarBits(BitSet a, BitSet b)
  4. createBitSetFromBinaryString(String bitsAsBinaryString)
  5. createSimpleBitSet(Set setBits)
  6. decodeIndex(final BitSet bs, final long rangePerDimension)
  7. deleteBits(BitSet bs, BitSet bsDelete)
  8. dualNext(BitSet b)
  9. encode(BitSet allowedCharacters, String s, String charset)