Java BitSet max(BitSet bits)

Here you can find the source of max(BitSet bits)

Description

get the largest member of the set

License

Open Source License

Parameter

Parameter Description
bits a parameter

Return

maximum member

Declaration

public static int max(BitSet bits) 

Method Source Code


//package com.java2s;
/*//from  w  ww . j av  a  2 s .c o  m
 * BitSetUtils.java Copyright (C) 2019. Daniel H. Huson
 *
 *  (Some files contain contributions from other authors, who are then mentioned separately.)
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.BitSet;

public class Main {
    /**
     * get the largest member of the set
     *
     * @param bits
     * @return maximum member
     */
    public static int max(BitSet bits) {
        int max = 0;
        for (int value = bits.nextSetBit(0); value != -1; value = bits.nextSetBit(value + 1)) {
            max = value;
        }
        return max;
    }
}

Related

  1. isSubSet(BitSet x, BitSet y)
  2. longFrom(final BitSet bitSet)
  3. longToBitSet(long bits)
  4. longToBitSet(long value)
  5. mapToBitSet(Map map, String key)
  6. members(BitSet set)
  7. nextClearBitModulo(int index, int poolSize, BitSet bitSet)
  8. not(BitSet bitSets)
  9. or(BitSet bs1, BitSet bs2)