Here you can find the source of expand(final BitSet bits, final BitSet add)
Parameter | Description |
---|---|
bits | The first BitSet. |
add | The second BitSet. |
public static BitSet expand(final BitSet bits, final BitSet add)
//package com.java2s; /**//from w w w . j a v a 2 s. c o m * Copyright (C) 2012 Ulrich Viefhaus * This file (ByteUtils.java) is from the package utils which is part of Hashchecker. * Hashchecker 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. * * Hashmaker and Hashviewer 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 Hashmaker and Hashviewer. If not, see <http://www.gnu.org/licenses/>. * * */ import java.util.BitSet; public class Main { /** * Fuses two given BitSets to one by adding the bits of the second at the * end of the first BitSet. The length of the result is the added length off * both given BitSets. * * @param bits * The first BitSet. * @param add * The second BitSet. */ public static BitSet expand(final BitSet bits, final BitSet add) { final BitSet result = (BitSet) bits.clone(); int index = result.length(); for (int i = 0; i < add.length(); i++) { if (add.get(i)) { result.set(index); } index++; } return result; } }