Cleaning up to bring into main. Speed problem seems to have dissapeard, but we have fixes and the ^ operator in here

This commit is contained in:
Nathan Braswell
2017-01-24 22:11:33 -05:00
parent f0a657e80f
commit 987e6eb9a5
3 changed files with 32 additions and 44 deletions

View File

@@ -47,28 +47,19 @@ fun min<T>(a: T, b: T): T {
return a;
}
fun hash<T>(item: T): ulong {
var h = hash_first(item)
/*h ^= h >> 16*/
/*h *= 0x85ebca6b*/
/*h ^= h >> 13*/
/*h *= 0xc2b2ae35*/
/*h ^= h >> 16*/
return h
}
fun hash<T(Hashable)>(item: T): ulong return item.hash()
fun hash<T>(item: *T): ulong return (item) cast ulong
fun hash(item: char): ulong return (item) cast ulong
fun hash(item: uchar): ulong return (item) cast ulong
fun hash(item: short): ulong return (item) cast ulong
fun hash(item: ushort): ulong return (item) cast ulong
fun hash(item: int): ulong return (item) cast ulong
fun hash(item: uint): ulong return (item) cast ulong
fun hash(item: long): ulong return (item) cast ulong
fun hash(item: ulong): ulong return (item) cast ulong
fun hash_first<T(Hashable)>(item: T): ulong return item.hash()
fun hash_first<T>(item: *T): ulong return (item) cast ulong
fun hash_first(item: char): ulong return (item) cast ulong
fun hash_first(item: uchar): ulong return (item) cast ulong
fun hash_first(item: short): ulong return (item) cast ulong
fun hash_first(item: ushort): ulong return (item) cast ulong
fun hash_first(item: int): ulong return (item) cast ulong
fun hash_first(item: uint): ulong return (item) cast ulong
fun hash_first(item: long): ulong return (item) cast ulong
fun hash_first(item: ulong): ulong return (item) cast ulong
// default hash
fun hash_first<T>(item: T): ulong {
fun hash<T>(item: T): ulong {
io::println("using empty hash - please do not do!")
return (0) cast ulong
}