BitSet shift Right - Java java.util

Java examples for java.util:BitSet

Description

BitSet shift Right

Demo Code


//package com.java2s;
import java.util.BitSet;

public class Main {
    public static void shiftRight(BitSet bs, int n) {
        for (int i = 0; i < bs.length() && i > -1; i = bs.nextSetBit(i + 1)) {
            bs.clear(i);/*w  w w  . j a  va  2  s  .  co  m*/
            if (i > 0)
                bs.set(i - 1);
        }
    }
}

Related Tutorials