Added more tests

-added Vector test
-added HashMap test
-added EntityMeta test
-added default hashing function to hashmap
This commit is contained in:
Mergul 2020-05-27 19:46:11 +02:00
parent 2f827a94db
commit f964d7bf85
6 changed files with 133 additions and 7 deletions

View file

@ -19,10 +19,21 @@ export ulong defaultHashFunc(T)(auto ref T t) nothrow @nogc
}
else
{
return 0; //hashInt(t.hashOf); // hashOf is not giving proper distribution between H1 and H2 hash parts
static if(isArray!T)return hashInt(hash((cast(byte*)t.ptr)[0 .. t.length * ForeachType!(T).sizeof]));
else return hashInt(hash((cast(byte*)&t)[0 .. T.sizeof])); //hashInt(t.hashOf); // hashOf is not giving proper distribution between H1 and H2 hash parts
}
}
ulong hash(byte[] array) nothrow @nogc
{
ulong hash = 0;
foreach(c;array)
hash = c + (hash << 6) + (hash << 16) - hash;
return hash;
}
// Can turn bad hash function to good one
export ulong hashInt(ulong x) nothrow @nogc @safe
{