集册 Java实例教程 一种可能很好奇的方法:b是一个参考集,某个分子中的所有原子可能是工作集,也许代表了所有显示的原子对于b中的每个设置位:a)如果a也被设置,则清除a位,除非b )如果未设置a,则将b的所有置位加到上,因此,如果a等于b

一种可能很好奇的方法:b是一个参考集,某个分子中的所有原子可能是工作集,也许代表了所有显示的原子对于b中的每个设置位:a)如果a也被设置,则清除a位,除非b )如果未设置a,则将b的所有置位加到上,因此,如果a等于b

欢马劈雪     最近更新时间:2020-01-02 10:19:05

416
一种可能很好奇的方法:b是一个参考集,某个分子中的所有原子可能是工作集,也许代表了所有显示的原子对于b中的每个设置位:a)如果a也被设置,则清除a的一位,除非b )如果未设置a,则将b的所有置位加到因此,如果a等于b->如果a是b的子集,则清除所有,然后-> b,如果b是a的子集,则- ->如果a仅与b相交,则a不是b,然后-> a或b如果a不与b相交,则a或b在“切换”模式下,当单击分子的任何原子时,您想要:(a)如果尚未显示,则要显示的分子中的所有原子,或者(b)如果已经显示了该分子的所有原子,则要隐藏的整个分子。

/* $RCSfile$

 * $Author: egonw $

 * $Date: 2005-11-10 09:52:44 -0600 (Thu, 10 Nov 2005) $

 * $Revision: 4255 $

 *

 * Copyright (C) 2003-2005  The Jmol Development Team

 *

 * Contact: jmol-developers@lists.sf.net

 *

 *  This library is free software; you can redistribute it and/or

 *  modify it under the terms of the GNU Lesser General Public

 *  License as published by the Free Software Foundation; either

 *  version 2.1 of the License, or (at your option) any later version.

 *

 *  This library 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

 *  Lesser General Public License for more details.

 *

 *  You should have received a copy of the GNU Lesser General Public

 *  License along with this library; if not, write to the Free Software

 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.

 */

//package com.nowjava;

import java.util.BitSet;//来自 时代Java - nowjava.com


public class Main {

    /**

     * a perhaps curious method:

     * 

     * b is a reference set, perhaps all atoms in a certain molecule a is the

     * working set, perhaps representing all displayed atoms

     * 

     * For each set bit in b: a) if a is also set, then clear a's bit UNLESS b) if

     * a is not set, then add to a all set bits of b

     * 

     * Thus, if a equals b --> clear all if a is a subset of b, then --> b if b is

     * a subset of a, then --> a not b if a only intersects with b, then --> a or

     * b if a does not intersect with b, then a or b

     * 

     * In "toggle" mode, when you click on any atom of the molecule, you want

     * either:

     * 

     * (a) all the atoms in the molecule to be displayed if not all are already

     * displayed, or

     * 

     * (b) the whole molecule to be hidden if all the atoms of the molecule are

     * already displayed.

     * 

     * @param a

     * @param b

     * @return a handy pointer to the working set, a

     */

    public static BitSet toggleInPlace(BitSet a, BitSet b) {

        if (a.equals(b)) {

            // all on -- toggle all off

            a.clear();

        } else if (andNot(copy(b), a).length() == 0) {

            // b is a subset of a -> remove all b bits from a

            andNot(a, b);

        } else {

            // may or may not be some overlap

            // combine a and b

            a.or(b);

        }

        return a;

    }


    public static BitSet andNot(BitSet a, BitSet b) {
    /**
     * 时代Java公众号 - nowjava.com 提 供 
    **/

        if (b != nul
展开阅读全文