/*
Copyright (C) 2000-2010  Ministere de la culture et de la communication (France), AJLSM
See LICENCE file
 */
package fr.gouv.culture.sdx.utils;

import java.util.BitSet;

/**
 * Utility methods to handle bitsets.
 */
public class Bits {

    /**
     *	Returns the number of bits set to 1 in a bitset.
     *
     *	@param	bs		The bitset to check.
     */
    public static int countBits(BitSet bs) {
        if (bs == null) return 0;
        int ret = 0;
        for (int i = 0; i < bs.length(); i++)
            if (bs.get(i)) ret++;
        return ret;
    }


}
