📄 ringsizecomparator.java
字号:
/* $RCSfile$ * $Author: kaihartmann $ * $Date: 2007-02-01 10:47:09 +0100 (Thu, 01 Feb 2007) $ * $Revision: 7811 $ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * Contact: cdk-devel@lists.sourceforge.net * * This program 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. * All we ask is that proper credit is given for our work, which includes * - but is not limited to - adding the above copyright notice to the beginning * of your source code files, and to any copyright notice that you may distribute * with programs based on this work. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */package org.openscience.cdk.tools.manipulator;import org.openscience.cdk.interfaces.IRing;/** * @cdk.module standard */public class RingSizeComparator implements java.util.Comparator { /** Flag to denote that the set is order with the largest ring first */ public final static int LARGE_FIRST = 1; /** Flag to denote that the set is order with the smallest ring first */ public final static int SMALL_FIRST = 2; int sortOrder = SMALL_FIRST; /** * Constructs a new comparator to sort rings by size. * * @param order Sort order: either RingSet.SMALL_FIRST or * RingSet.LARGE_FIRST. */ public RingSizeComparator(int order) { sortOrder = order; } public int compare(Object object1, Object object2) throws ClassCastException { int size1 = ((IRing)object1).getAtomCount(); int size2 = ((IRing)object2).getAtomCount(); if (size1 == size2) return 0; if (size1 > size2 && sortOrder == SMALL_FIRST) { return 1; } if (size1 > size2 && sortOrder == LARGE_FIRST) { return -1; } if (size1 < size2 && sortOrder == SMALL_FIRST) { return -1; } if (size1 < size2 && sortOrder == LARGE_FIRST) { return 1; } return 0; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -