From e241034942725b7a189cb6186fd331d9defde7bc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 30 Jul 2015 02:50:38 +0200 Subject: Introduce Bitfield interface w/ Int32 and Int32Array impl. deprecating IntBitfield IntBitfield's 64bit bit-size is exceeding its use-case, making it less efficient and complicated. Bitfield offers a fast path implementation for 32 bits as well as a int[] implementation. TODO: 32 bit Unaligned putInt32(..) and getInt32(..), currently throwing UnsupportedOperationException for int[] impl. --- src/java/com/jogamp/common/util/IntBitfield.java | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/java/com/jogamp/common/util/IntBitfield.java') diff --git a/src/java/com/jogamp/common/util/IntBitfield.java b/src/java/com/jogamp/common/util/IntBitfield.java index 74e37ac..3ef5bb7 100644 --- a/src/java/com/jogamp/common/util/IntBitfield.java +++ b/src/java/com/jogamp/common/util/IntBitfield.java @@ -28,7 +28,10 @@ package com.jogamp.common.util; /** + * @deprecated Use {@link Bitfield} implementations via {@link Bitfield.Factory#create(int)}. + *

* Simple bitfield holder class using an int[] storage. + *

*

* IntBitfield allows convenient access of a wide field of transient bits using efficient storage in O(1). *

@@ -137,21 +140,10 @@ public class IntBitfield { return prev; } /** - * Returns the number of set bits within given 32bit integer in O(1) - * using HAKEM Bit Count: - *
-     *   http://www.inwap.com/pdp10/hbaker/hakmem/hakmem.html
-     *   http://home.pipeline.com/~hbaker1/hakmem/hacks.html#item169
-     *   http://tekpool.wordpress.com/category/bit-count/
-     * 
+ * @deprecated Use {@link Bitfield.Util#getBitCount(int)}. */ public static final int getBitCount(final int n) { - // Note: Original used 'unsigned int', - // hence we use the unsigned right-shift '>>>' - int c = n; - c -= (n >>> 1) & 033333333333; - c -= (n >>> 2) & 011111111111; - return ( (c + ( c >>> 3 ) ) & 030707070707 ) % 63; + return Bitfield.Util.getBitCount(n); } /** @@ -163,7 +155,7 @@ public class IntBitfield { public long getBitCount() { long c = 0; for(int i = storage.length-1; i>=0; i--) { - c += getBitCount(storage[i]); + c += Bitfield.Util.getBitCount(storage[i]); } return c; } -- cgit v1.2.3