xxhash added
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
uint32 hash_sdbm32(uint32 oldhash, void* buf, uint32 len){
|
||||
uint8* ubuf=(uint8*)buf;
|
||||
uint32 hash=oldhash;
|
||||
register uint32 hash=oldhash;
|
||||
for (; len ; len--, ubuf++)
|
||||
hash=*ubuf+(hash<<6)+(hash<<16)-hash;
|
||||
hash=(hash<<6)+(hash<<16)-hash+*ubuf;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -79,10 +79,11 @@ uint32 hash_crc32(uint32 oldhash, void* buf, uint32 len){
|
||||
uint8* ubuf=(uint8*)buf;
|
||||
register uint32 crc=oldhash;
|
||||
for (; len; --len, ++ubuf)
|
||||
crc = crc_32_tab[(crc^(*ubuf)) & 0xff] ^ (crc>>8);
|
||||
crc=crc_32_tab[(crc^(*ubuf)) & 0xff] ^ (crc>>8);
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
|
||||
// bool hashf_crc32c(char *name, uint32 *crc, long *charcnt) {
|
||||
// register FILE *fin;
|
||||
// register uint32 oldcrc32;
|
||||
@@ -11,6 +11,8 @@ extern "C" {
|
||||
|
||||
uint32 hash_sdbm32(uint32 oldhash, void* buf, uint32 len);
|
||||
uint32 hash_crc32(uint32 oldhash, void* buf, uint32 len);
|
||||
uint32 hash_xxh32(uint32 oldhash, void* buf, uint32 len);
|
||||
uint64 hash_xxh3_64(uint32 oldhash, void* buf, uint32 len);
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
12
src/HashFunctions/xxhash.c
Normal file
12
src/HashFunctions/xxhash.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "hash.h"
|
||||
#define XXH_INLINE_ALL
|
||||
#define XXH_STATIC_LINKING_ONLY /* access advanced declarations */
|
||||
#define XXH_IMPLEMENTATION /* access definitions */
|
||||
#include "./xxhash.h"
|
||||
|
||||
uint32 hash_xxh32(uint32 oldhash, void* buf, uint32 len){
|
||||
return XXH32(buf,len,oldhash);
|
||||
}
|
||||
uint64 hash_xxh3_64(uint32 oldhash, void* buf, uint32 len){
|
||||
return XXH3_64bits_withSeed(buf,len,oldhash);
|
||||
}
|
||||
6075
src/HashFunctions/xxhash.h
Normal file
6075
src/HashFunctions/xxhash.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "hash.h"
|
||||
#include "../HashFunctions/hash.h"
|
||||
#include "KeyValuePair.h"
|
||||
|
||||
typedef struct Hashtable{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Hashtable/hash.h"
|
||||
#include "../HashFunctions/hash.h"
|
||||
#include "../Autoarr2/Autoarr2.hpp"
|
||||
|
||||
// amount of rows
|
||||
@@ -129,6 +129,7 @@ bool Hashtable2<TKey, TVal>::remove(TKey){
|
||||
|
||||
template<typename TKey, typename TVal>
|
||||
Hashtable2<TKey, TVal>::~Hashtable2(){
|
||||
delete[] hashes;
|
||||
delete[] keys;
|
||||
delete[] values;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,6 @@ extern "C" {
|
||||
#include <time.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#define CHOOSE(B, Y, N) __builtin_choose_expr(B, Y, N)
|
||||
|
||||
#define IFTYPE(X, T) __builtin_types_compatible_p(typeof(X), T)
|
||||
|
||||
#define dbg(N) printf("\e[95m%d\n",N)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user