public static boolean hasItem(IntHashTable ht, int key) { int mask = ht.mask; int hash = MurmurHash.hash32finalizer(key); long block = ht.data[hash & mask]; while (((int)block) != key && block != 0) { block = ht.data[++hash & mask]; } return 0!=block; }
public static boolean replaceItem(IntHashTable ht, int key, int newValue) { int mask = ht.mask; int hash = MurmurHash.hash32finalizer(key); int temp = (int)ht.data[hash&mask];//just the lower int. while (temp != key && temp != 0) { temp = (int)ht.data[++hash & mask]; } if (0 == temp) { return false; //do not set item if it does not hold a previous value. } long block = newValue; block = (block<<32) | (0xFFFFFFFF&key); ht.data[hash&mask] = block; return true; }
public static boolean hasItem(IntHashTable ht, int key) { int mask = ht.mask; int hash = MurmurHash.hash32finalizer(key); long block = ht.data[hash & mask]; while (((int)block) != key && block != 0) { block = ht.data[++hash & mask]; } return 0!=block; }
public static boolean replaceItem(IntHashTable ht, int key, int newValue) { int mask = ht.mask; int hash = MurmurHash.hash32finalizer(key); int temp = (int)ht.data[hash&mask];//just the lower int. while (temp != key && temp != 0) { temp = (int)ht.data[++hash & mask]; } if (0 == temp) { return false; //do not set item if it does not hold a previous value. } long block = newValue; block = (block<<32) | (0xFFFFFFFF&key); ht.data[hash&mask] = block; return true; }
public static boolean hasItem(IntHashTable ht, int key) { int mask = ht.mask; int hash = MurmurHash.hash32finalizer(key); long block = ht.data[hash & mask]; while (((int)block) != key && block != 0) { block = ht.data[++hash & mask]; } return 0!=block; }
public static boolean replaceItem(IntHashTable ht, int key, int newValue) { int mask = ht.mask; int hash = MurmurHash.hash32finalizer(key); int temp = (int)ht.data[hash&mask];//just the lower int. while (temp != key && temp != 0) { temp = (int)ht.data[++hash & mask]; } if (0 == temp) { return false; //do not set item if it does not hold a previous value. } long block = newValue; block = (block<<32) | (0xFFFFFFFF&key); ht.data[hash&mask] = block; return true; }
public static int hash64finalizer(long value) { return hash32finalizer( ((int)(value>>32)) | (int)value ); }
public static int hash64finalizer(long value) { return hash32finalizer( ((int)(value>>32)) | (int)value ); }
public static int hash64finalizer(long value) { return hash32finalizer( ((int)(value>>32)) | (int)value ); }
public static boolean setItem(IntHashTable ht, int key, int value) { if (0==key || 0==ht.space) { return false; } long block = value; block = (block<<32) | (0xFFFFFFFFL&key); int mask = ht.mask; int hash = MurmurHash.hash32finalizer(key); int temp = (int)ht.data[hash&mask];//just the lower int. while (temp != key && temp != 0) { temp = (int)ht.data[++hash & mask]; } if (0 != temp) { // System.err.println("held prev value of "+temp+" when setting "+value); return false; //do not set item if it holds a previous value. } ht.data[hash&mask] = block; ht.space--;//gives up 1 spot as a stopper for get. return true; }
public static boolean setItem(IntHashTable ht, int key, int value) { if (0==key || 0==ht.space) { return false; } long block = value; block = (block<<32) | (0xFFFFFFFFL&key); int mask = ht.mask; int hash = MurmurHash.hash32finalizer(key); int temp = (int)ht.data[hash&mask];//just the lower int. while (temp != key && temp != 0) { temp = (int)ht.data[++hash & mask]; } if (0 != temp) { // System.err.println("held prev value of "+temp+" when setting "+value); return false; //do not set item if it holds a previous value. } ht.data[hash&mask] = block; ht.space--;//gives up 1 spot as a stopper for get. return true; }
public static boolean setItem(IntHashTable ht, int key, int value) { if (0==key || 0==ht.space) { return false; } long block = value; block = (block<<32) | (0xFFFFFFFFL&key); int mask = ht.mask; int hash = MurmurHash.hash32finalizer(key); int temp = (int)ht.data[hash&mask];//just the lower int. while (temp != key && temp != 0) { temp = (int)ht.data[++hash & mask]; } if (0 != temp) { // System.err.println("held prev value of "+temp+" when setting "+value); return false; //do not set item if it holds a previous value. } ht.data[hash&mask] = block; ht.space--;//gives up 1 spot as a stopper for get. return true; }
/** * returns zero if the value is not found otherwise it returns the value. * If zero was set as the value there is no way to tell the difference without calling hasItem * @param ht * @param key */ public static int getItem(IntHashTable ht, int key) { int hash = MurmurHash.hash32finalizer(key); return (int)(scanForItem(key, ht.mask, hash, ht.data, ht.data[hash & ht.mask]) >> 32); }
/** * returns zero if the value is not found otherwise it returns the value. * If zero was set as the value there is no way to tell the difference without calling hasItem * @param ht * @param key */ public static int getItem(IntHashTable ht, int key) { int hash = MurmurHash.hash32finalizer(key); return (int)(scanForItem(key, ht.mask, hash, ht.data, ht.data[hash & ht.mask]) >> 32); }
/** * returns zero if the value is not found otherwise it returns the value. * If zero was set as the value there is no way to tell the difference without calling hasItem * @param ht * @param key */ public static int getItem(IntHashTable ht, int key) { int hash = MurmurHash.hash32finalizer(key); return (int)(scanForItem(key, ht.mask, hash, ht.data, ht.data[hash & ht.mask]) >> 32); }