Initial
This commit is contained in:
parent
d4c558a59a
commit
db05d963be
74 changed files with 4473 additions and 3231 deletions
46
BaseModule/private/Common.cpp
Normal file
46
BaseModule/private/Common.cpp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
#include "Common.hpp"
|
||||
|
||||
namespace tp {
|
||||
ualni next2pow(ualni v) {
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
v |= v >> 32;
|
||||
return v + 1;
|
||||
}
|
||||
|
||||
uhalni next2pow(uhalni v) {
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
return v + 1;
|
||||
}
|
||||
|
||||
ufalni next2pow(ufalni v) {
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
return v + 1;
|
||||
}
|
||||
|
||||
ualni hash(const char* bytes) {
|
||||
unsigned long hash = 5381;
|
||||
int c;
|
||||
while ((c = *bytes++)) {
|
||||
hash = ((hash << 5) + hash) + c;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
ualni hash(alni bytes) { return abs(bytes); }
|
||||
ualni hash(alnf bytes) { return (alni)(abs(bytes)); }
|
||||
ualni hash(halni bytes) { return hash(alni(bytes)); }
|
||||
ualni hash(uhalni bytes) { return hash(alni(bytes)); }
|
||||
ualni hash(ualni bytes) { return hash(alni(bytes)); }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue