summaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-03-13 01:30:38 +0100
committerSven Gothel <[email protected]>2013-03-13 01:30:38 +0100
commit8457bf35fee253d9af29ff1150a9671f6896fc17 (patch)
treebc263d46dd7d924202717ace4d72aafefa2ce1bb /src/jogl
parent6b924839b33dbf507dd9eebc0ad5b5fbf23f4fb2 (diff)
MemoryObject: Use GlueGen's new HashUtil
GlueGen commit 1a4514accc8f61ab7ff5fe8c82d22a5ef356c865
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/jogamp/opengl/MemoryObject.java50
1 files changed, 6 insertions, 44 deletions
diff --git a/src/jogl/classes/jogamp/opengl/MemoryObject.java b/src/jogl/classes/jogamp/opengl/MemoryObject.java
index 292700701..df793dadd 100644
--- a/src/jogl/classes/jogamp/opengl/MemoryObject.java
+++ b/src/jogl/classes/jogamp/opengl/MemoryObject.java
@@ -31,19 +31,21 @@ package jogamp.opengl;
import java.nio.ByteBuffer;
import java.util.HashMap;
+import com.jogamp.common.util.HashUtil;
+
/**
*
*/
public class MemoryObject {
private long addr;
private long size;
- private int hash32;
+ private int hash;
private ByteBuffer buffer=null;
public MemoryObject(long addr, long size) {
this.addr = addr;
this.size = size;
- this.hash32 = getHash32(addr, size);
+ this.hash = HashUtil.getAddrSizeHash32_EqualDist(addr, size);
}
public void setBuffer(ByteBuffer buffer) {
@@ -55,54 +57,14 @@ public class MemoryObject {
}
/**
- * @return the 32bit hash value generated via {@link #getHash32(long, long)}
+ * @return the 32bit hash value generated via {@link HashUtil#getAddrSizeHash32_EqualDist(long, long)}.
*/
public int hashCode() {
- return hash32;
- }
-
- /**
- * Ignores the optional attached <code>ByteBuffer</code> intentionally.<br>
- *
- * @return true of reference is equal or <code>obj</code> is of type <code>MemoryObject</code>
- * and <code>addr</code> and <code>size</code> is equal.<br>
- */
- public boolean equals(Object obj) {
- if(this == obj) { return true; }
- if(obj instanceof MemoryObject) {
- MemoryObject m = (MemoryObject) obj;
- return addr == m.addr && size == m.size ;
- }
- return false;
- }
-
- /**
- * Generates a 32bit hash value by <code>addr</code> and <code>size</code>.<br>
- * Ignores the optional attached <code>ByteBuffer</code> intentionally.<br>
- */
- public static int getHash32(long addr, long size) {
- // avoid xor collisions of eg low/high parts
- // 31 * x == (x << 5) - x
- int hash = 31 + (int) addr ; // lo addr
- hash = ((hash << 5) - hash) + (int) ( addr >>> 32 ) ; // hi addr
- hash = ((hash << 5) - hash) + (int) size ; // lo size
- hash = ((hash << 5) - hash) + (int) ( size >>> 32 ) ; // hi size
-
return hash;
}
- /**
- * Generates a 64bit hash value by <code>addr</code> and <code>size</code>.<br>
- * Ignores the optional attached <code>ByteBuffer</code> intentionally.<br>
- */
- public static long getHash64(long addr, long size) {
- // 31 * x == (x << 5) - x
- final long hash = 31 + addr;
- return ((hash << 5) - hash) + size;
- }
-
public String toString() {
- return "MemoryObject[addr 0x"+Long.toHexString(addr)+", size 0x"+Long.toHexString(size)+", hash32: 0x"+Integer.toHexString(hash32)+"]";
+ return "MemoryObject[addr 0x"+Long.toHexString(addr)+", size 0x"+Long.toHexString(size)+", hash32: 0x"+Integer.toHexString(hash)+"]";
}
/**