Java BitSet generateBitSetBySize(int size, boolean initValue)

Here you can find the source of generateBitSetBySize(int size, boolean initValue)

Description

generate a BitSet by size

License

Apache License

Parameter

Parameter Description
size a parameter
initValue true: initialize all bits to true

Declaration

public static BitSet generateBitSetBySize(int size, boolean initValue) 

Method Source Code

//package com.java2s;
/*/*from  w w  w. j a  va  2 s. com*/
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.BitSet;

public class Main {
    /**
     * generate a BitSet by size
     * @param size
     * @param initValue true: initialize all bits to true
     * @return
     */
    public static BitSet generateBitSetBySize(int size, boolean initValue) {
        BitSet bitSet = new BitSet(size);
        if (initValue) {
            bitSet.set(0, size);
        }
        return bitSet;
    }
}

Related

  1. filtered(final Iterator iterator, final BitSet filter)
  2. findTrue(BitSet set)
  3. firstIndexOfChar(String sqlString, BitSet keys, int startindex)
  4. firstInvalidOctet(CharSequence cs, BitSet bits)
  5. formatBitset(BitSet bitset, int width)
  6. getBiggerRang(BitSet bitSet)
  7. getBitSet()
  8. getBitSetFromBooleanArray(boolean[] buf)
  9. getLemma(String[] tokens, BitSet bits, String delimiter)