mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-26 21:34:42 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -1,77 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
// Java doesn't have a default hash value for ints, however, the hashmap itself does some "supplemental" hashing, so
|
||||
// our ints actually get hashed by code as implemented below. std templates *do* have a standard hash for ints, but it
|
||||
// would appear to be a bit expensive so matching the java one for now anyway. This code implements the supplemental
|
||||
// hashing that happens in java so we can match what their maps are doing with ints.
|
||||
// Java doesn't have a default hash value for ints, however, the hashmap itself
|
||||
// does some "supplemental" hashing, so our ints actually get hashed by code as
|
||||
// implemented below. std templates *do* have a standard hash for ints, but it
|
||||
// would appear to be a bit expensive so matching the java one for now anyway.
|
||||
// This code implements the supplemental hashing that happens in java so we can
|
||||
// match what their maps are doing with ints.
|
||||
|
||||
struct IntKeyHash
|
||||
{
|
||||
int operator() (const int &k) const
|
||||
{
|
||||
// 4jcraft added h to be unsigned, to not cast it later
|
||||
unsigned int h = k;
|
||||
struct IntKeyHash {
|
||||
int operator()(const int& k) const {
|
||||
// 4jcraft added h to be unsigned, to not cast it later
|
||||
unsigned int h = k;
|
||||
h += ~(h << 9);
|
||||
h ^= (h >> 14);
|
||||
h += (h << 4);
|
||||
h ^= (h >> 10);
|
||||
return h;
|
||||
}
|
||||
h ^= (h >> 14);
|
||||
h += (h << 4);
|
||||
h ^= (h >> 10);
|
||||
return h;
|
||||
}
|
||||
};
|
||||
|
||||
struct IntKeyEq
|
||||
{
|
||||
bool operator() (const int &x, const int &y) const { return x==y; }
|
||||
struct IntKeyEq {
|
||||
bool operator()(const int& x, const int& y) const { return x == y; }
|
||||
};
|
||||
|
||||
|
||||
// This hash functor is taken from the IntHashMap java class used by the game, so that we can use a standard std hashmap with this hash rather
|
||||
// than implement the class itself
|
||||
struct IntKeyHash2
|
||||
{
|
||||
int operator() (const int &k) const
|
||||
{
|
||||
unsigned int h = (unsigned int)k;
|
||||
// This hash functor is taken from the IntHashMap java class used by the game,
|
||||
// so that we can use a standard std hashmap with this hash rather than
|
||||
// implement the class itself
|
||||
struct IntKeyHash2 {
|
||||
int operator()(const int& k) const {
|
||||
unsigned int h = (unsigned int)k;
|
||||
h ^= (h >> 20) ^ (h >> 12);
|
||||
return (int)(h ^ (h >> 7) ^ (h >> 4));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// This hash functor is taken from the LongHashMap java class used by the game, so that we can use a standard std hashmap with this hash rather
|
||||
// than implement the class itself
|
||||
struct LongKeyHash
|
||||
{
|
||||
int hash(const int &k) const
|
||||
{
|
||||
unsigned int h = (unsigned int)k;
|
||||
// This hash functor is taken from the LongHashMap java class used by the game,
|
||||
// so that we can use a standard std hashmap with this hash rather than
|
||||
// implement the class itself
|
||||
struct LongKeyHash {
|
||||
int hash(const int& k) const {
|
||||
unsigned int h = (unsigned int)k;
|
||||
h ^= (h >> 20) ^ (h >> 12);
|
||||
return (int)(h ^ (h >> 7) ^ (h >> 4));
|
||||
}
|
||||
}
|
||||
|
||||
int operator() (const __int64 &k) const
|
||||
{
|
||||
return hash((int) ( k ^ (((__uint64)k) >> 32 )));
|
||||
}
|
||||
int operator()(const __int64& k) const {
|
||||
return hash((int)(k ^ (((__uint64)k) >> 32)));
|
||||
}
|
||||
};
|
||||
|
||||
struct LongKeyEq
|
||||
{
|
||||
bool operator() (const __int64 &x, const __int64 &y) const { return x==y; }
|
||||
struct LongKeyEq {
|
||||
bool operator()(const __int64& x, const __int64& y) const { return x == y; }
|
||||
};
|
||||
|
||||
struct eINSTANCEOFKeyHash
|
||||
{
|
||||
int operator() (const eINSTANCEOF &k) const
|
||||
{
|
||||
unsigned int h = (unsigned int)k;
|
||||
struct eINSTANCEOFKeyHash {
|
||||
int operator()(const eINSTANCEOF& k) const {
|
||||
unsigned int h = (unsigned int)k;
|
||||
h ^= (h >> 20) ^ (h >> 12);
|
||||
return (int)(h ^ (h >> 7) ^ (h >> 4));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct eINSTANCEOFKeyEq
|
||||
{
|
||||
bool operator() (const eINSTANCEOF &x, const eINSTANCEOF &y) const { return x==y; }
|
||||
struct eINSTANCEOFKeyEq {
|
||||
bool operator()(const eINSTANCEOF& x, const eINSTANCEOF& y) const {
|
||||
return x == y;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user