Java BitSet ensureExclusivity(BitSet bs1, BitSet bs2)

Here you can find the source of ensureExclusivity(BitSet bs1, BitSet bs2)

Description

Adjust two bitsets so that they do not overlap

License

Open Source License

Parameter

Parameter Description
bs1 the first bitset
bs2 the second bitset

Declaration

public static void ensureExclusivity(BitSet bs1, BitSet bs2) 

Method Source Code


//package com.java2s;
/*//  www . jav  a2s . c o  m
 *  NMerge is Copyright 2009 Desmond Schmidt
 * 
 *  This file is part of NMerge. NMerge is a Java library for merging 
 *  multiple versions into multi-version documents (MVDs), and for 
 *  reading, searching and comparing them.
 *
 *  NMerge 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.
 *
 *  NMerge 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 {
    /**
     * Adjust two bitsets so that they do not overlap
     * @param bs1 the first bitset
     * @param bs2 the second bitset
     */
    public static void ensureExclusivity(BitSet bs1, BitSet bs2) {
        if (bs1.cardinality() > bs2.cardinality()) {
            bs1.andNot(bs2);
            bs2.andNot(bs1);
        } else {
            bs2.andNot(bs1);
            bs1.andNot(bs2);
        }
    }
}

Related

  1. deleteBits(BitSet bs, BitSet bsDelete)
  2. dualNext(BitSet b)
  3. encode(BitSet allowedCharacters, String s, String charset)
  4. encode(BitSet origin, int originBitLength)
  5. encode(String s, BitSet bs)
  6. escape(String s, BitSet safeChars)
  7. expand(final BitSet bits, final BitSet add)
  8. extractLong(BitSet bitSet, int from, int to)
  9. extractSetBitsMsgFromTxSet(final BitSet txSet)