Java BitSet copyBits(BitSet source, BitSet dest, int fromIndex)

Here you can find the source of copyBits(BitSet source, BitSet dest, int fromIndex)

Description

Copy bits completely from a source BitSet to a destination BitSet starting at the destination index

License

Open Source License

Parameter

Parameter Description
source a parameter
dest a parameter
fromIndex a parameter

Declaration

public static BitSet copyBits(BitSet source, BitSet dest, int fromIndex) 

Method Source Code

//package com.java2s;
/* Image to ZX Spec/*from   w ww  . ja va 2s  . c om*/
 * Copyright (C) 2014 Silent Software (Benjamin Brown)
 *
 * 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 2
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import java.util.BitSet;

public class Main {
    /**
     * Copy bits completely from a source BitSet to 
     * a destination BitSet starting at the destination
     * index
     * 
     * @param source
     * @param dest
     * @param fromIndex
     * @return
     */
    public static BitSet copyBits(BitSet source, BitSet dest, int fromIndex) {
        for (int i = 0; i < source.length(); i++) {
            if (source.get(i)) {
                dest.set(fromIndex + i);
            }
        }
        return dest;
    }
}

Related

  1. checkValidCharOnly(BitSet validChars, String value)
  2. clear(BitSet bitSet_)
  3. combine(int length, BitSet... bitsets)
  4. compare(BitSet a, BitSet b)
  5. copy(BitSet bs)
  6. copyBitSetToBitSet(BitSet src, int srcPos, BitSet dest, int destPos, int length)
  7. countLeadingSimilarBits(BitSet a, BitSet b)
  8. createBitSetFromBinaryString(String bitsAsBinaryString)
  9. createSimpleBitSet(Set setBits)