From: <ha...@us...> - 2010-02-08 22:30:16
|
Revision: 12345 http://jmol.svn.sourceforge.net/jmol/?rev=12345&view=rev Author: hansonr Date: 2010-02-08 22:29:57 +0000 (Mon, 08 Feb 2010) Log Message: ----------- FastBitSet Modified Paths: -------------- trunk/Jmol/src/org/jmol/geodesic/EnvelopeCalculation.java trunk/Jmol/src/org/jmol/shapespecial/Dots.java trunk/Jmol/src/org/jmol/util/FastBitSet.java trunk/Jmol/src/org/jmol/util/SlowBitSet.java Modified: trunk/Jmol/src/org/jmol/geodesic/EnvelopeCalculation.java =================================================================== --- trunk/Jmol/src/org/jmol/geodesic/EnvelopeCalculation.java 2010-02-08 19:29:32 UTC (rev 12344) +++ trunk/Jmol/src/org/jmol/geodesic/EnvelopeCalculation.java 2010-02-08 22:29:57 UTC (rev 12345) @@ -149,15 +149,15 @@ this.mads = mads; geodesicCount = Geodesic.getVertexVectorsCount(); - if (asJavaBitSet) { - geodesicMap = SlowBitSet.allocateBitmap(geodesicCount); - mapT = SlowBitSet.allocateBitmap(geodesicCount); - emptySet = SlowBitSet.nullMap; - } else { + //if (asJavaBitSet) { + // geodesicMap = SlowBitSet.allocateBitmap(geodesicCount); + // mapT = SlowBitSet.allocateBitmap(geodesicCount); + // emptySet = new SlowBitSet(); + //} else { geodesicMap = FastBitSet.allocateBitmap(geodesicCount); mapT = FastBitSet.allocateBitmap(geodesicCount); emptySet = FastBitSet.getEmptySet(); - } + //} } Modified: trunk/Jmol/src/org/jmol/shapespecial/Dots.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/Dots.java 2010-02-08 19:29:32 UTC (rev 12344) +++ trunk/Jmol/src/org/jmol/shapespecial/Dots.java 2010-02-08 22:29:57 UTC (rev 12345) @@ -286,8 +286,7 @@ if (bsColixSet != null && bsColixSet.get(i)) setStateInfo(temp, i, getColorCommand(type, paletteIDs[i], colixes[i])); FastBitSet bs = dotsConvexMaps[i]; - int n = bs.size(); - if (n > 0) { + if (!bs.isEmpty()) { float r = ec.getAppropriateRadius(i); appendCmd(s, type + i + " radius " + r + " " + Escape.escape(bs.toBitSet())); Modified: trunk/Jmol/src/org/jmol/util/FastBitSet.java =================================================================== --- trunk/Jmol/src/org/jmol/util/FastBitSet.java 2010-02-08 19:29:32 UTC (rev 12344) +++ trunk/Jmol/src/org/jmol/util/FastBitSet.java 2010-02-08 22:29:57 UTC (rev 12345) @@ -159,11 +159,11 @@ } public void or(FastBitSet setOr) { - bitmapOr(ensureSufficientWords(bitmap, setOr.bitmap.length), setOr.bitmap); + bitmapOr(bitmap = ensureSufficientWords(bitmap, setOr.bitmap.length), setOr.bitmap); } public void set(int bitIndex) { - bitmapSetBit(ensureSufficientBits(bitmap, bitIndex + 1), bitIndex); + bitmapSetBit(bitmap = ensureSufficientBits(bitmap, bitIndex + 1), bitIndex); } public void set(int bitIndex, boolean value) { @@ -174,7 +174,7 @@ } public void set(int fromIndex, int toIndex) { - bitmapSetRange(ensureSufficientBits(bitmap, toIndex), fromIndex, toIndex + bitmapSetRange(bitmap = ensureSufficientBits(bitmap, toIndex), fromIndex, toIndex - fromIndex); } @@ -190,7 +190,7 @@ } public void xor(FastBitSet setXor) { - bitmapXor(ensureSufficientWords(bitmap, setXor.bitmap.length), + bitmapXor(bitmap = ensureSufficientWords(bitmap, setXor.bitmap.length), setXor.bitmap); } @@ -492,20 +492,17 @@ // / testing: /* - FastBitSet(java.util.BitSet bs) { - bitmap = new int[getWordCountFromBitCount(bs.size())]; - for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) - set(i); - } - - static { - - FastBitSet bs = new FastBitSet(Escape.unescapeBitset("{(33:45 75:80)}")); - System.out.println(bs.cardinality()); - System.out.println(bs.cardinality(35)); - // ...do whatever here... System.out.println(bs); - - } - - */ + * FastBitSet(java.util.BitSet bs) { bitmap = new + * int[getWordCountFromBitCount(bs.size())]; for (int i = bs.nextSetBit(0); i + * >= 0; i = bs.nextSetBit(i + 1)) set(i); } + * + * static { + * + * FastBitSet bs = new FastBitSet(Escape.unescapeBitset("{(33:45 75:80)}")); + * System.out.println(bs.cardinality()); + * System.out.println(bs.cardinality(35)); // ...do whatever here... + * System.out.println(bs); + * + * } + */ } Modified: trunk/Jmol/src/org/jmol/util/SlowBitSet.java =================================================================== --- trunk/Jmol/src/org/jmol/util/SlowBitSet.java 2010-02-08 19:29:32 UTC (rev 12344) +++ trunk/Jmol/src/org/jmol/util/SlowBitSet.java 2010-02-08 22:29:57 UTC (rev 12345) @@ -23,30 +23,42 @@ */ package org.jmol.util; -import java.util.BitSet; /* * for comparison purposes -- the standard BitSet implementation (dots and geosurfaces only) * implemented by EnvelopeCalculation using set testflag2 TRUE + * + * needs full implemention of public FastBitSet methods to work properly. + * */ -public class SlowBitSet extends FastBitSet { - - public final static SlowBitSet nullMap = new SlowBitSet(); - +public class SlowBitSet {//extends FastBitSet { +/* public static FastBitSet allocateBitmap(int count) { return new SlowBitSet(count, true); } - private BitSet bs; + private java.util.BitSet bs; public SlowBitSet() { - bs = new BitSet(); + bs = new java.util.BitSet(); } protected SlowBitSet(int count, boolean asBits) { - bs = new BitSet(asBits ? count : count * 64 ); + bs = new java.util.BitSet(asBits ? count : count * 64 ); } + protected SlowBitSet(FastBitSet bsToCopy) { + bs = (java.util.BitSet) ((SlowBitSet) bsToCopy).bs.clone(); + } + + public void and(FastBitSet setAnd) { + bs.and(((SlowBitSet) setAnd).bs); + } + + public void andNot(FastBitSet setAndNot) { + bs.andNot(((SlowBitSet) setAndNot).bs); + } + public int cardinality() { return bs.cardinality(); } @@ -69,32 +81,48 @@ public Object clone() { SlowBitSet result = new SlowBitSet(); - result.bs = (BitSet) bs.clone(); + result.bs = (java.util.BitSet) bs.clone(); return result; } - + public FastBitSet copy() { return (SlowBitSet) clone(); } + public boolean equals(Object obj) { + return (obj instanceof SlowBitSet && ((SlowBitSet) obj).bs.equals(bs)); + } + + public void flip(int i) { + bs.flip(i); + } + public boolean get(int i) { return bs.get(i); } - /* + public void setAllBits(int count) { bs.set(0, count); } - */ - public int getMapStorageCount() { - return bs.size() * 64; + + public boolean isEmpty() { + return bs.isEmpty(); } - public int hashCode() { - return bs.hashCode(); + public int length() { + return bs.length(); } + public int nextSetBit(int fromIndex) { + return bs.nextSetBit(fromIndex); + } + + public void or(FastBitSet setOr) { + bs.or(((SlowBitSet) setOr).bs); + } + public void set(int i) { bs.set(i); } @@ -107,11 +135,21 @@ return bs.size(); } - public BitSet toBitSet() { + public void xor(FastBitSet setXor) { + bs.xor(((SlowBitSet) setXor).bs); + } + + public java.util.BitSet toBitSet() { return BitSetUtil.copy(bs); } public String toString() { return Escape.escape(bs); } + + public int hashCode() { + return bs.hashCode(); + } + +*/ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |