1
0
mirror of https://github.com/exaloop/codon.git synced 2025-06-03 15:03:52 +08:00

stdlib/internal/khash.codon

This commit is contained in:
Ishak Numanagić 2022-01-24 08:06:28 +01:00
parent eee893b32a
commit f8e29e2a3a

View File

@ -1,23 +1,33 @@
def __ac_isempty(flag: Ptr[u32], i: int):
return int(flag[i >> 4] >> u32((i & 0xf) << 1)) & 2
# (c) 2022 Exaloop Inc. All rights reserved.
def __ac_isdel(flag: Ptr[u32], i: int):
return int(flag[i >> 4] >> u32((i & 0xf) << 1)) & 1
def __ac_iseither(flag: Ptr[u32], i: int):
return int(flag[i >> 4] >> u32((i & 0xf) << 1)) & 3
def __ac_isempty(flag: Ptr[u32], i: int) -> int:
return int(flag[i >> 4] >> u32((i & 0xF) << 1)) & 2
def __ac_set_isdel_false(flag: Ptr[u32], i: int):
flag[i >> 4] &= u32(~(1 << ((i & 0xf) << 1)))
def __ac_set_isempty_false(flag: Ptr[u32], i: int):
flag[i >> 4] &= u32(~(2 << ((i & 0xf) << 1)))
def __ac_isdel(flag: Ptr[u32], i: int) -> int:
return int(flag[i >> 4] >> u32((i & 0xF) << 1)) & 1
def __ac_set_isboth_false(flag: Ptr[u32], i: int):
flag[i >> 4] &= u32(~(3 << ((i & 0xf) << 1)))
def __ac_set_isdel_true(flag: Ptr[u32], i: int):
flag[i >> 4] |= u32(1 << ((i & 0xf) << 1))
def __ac_iseither(flag: Ptr[u32], i: int) -> int:
return int(flag[i >> 4] >> u32((i & 0xF) << 1)) & 3
def __ac_fsize(m):
def __ac_set_isdel_false(flag: Ptr[u32], i: int) -> void:
flag[i >> 4] &= u32(~(1 << ((i & 0xF) << 1)))
def __ac_set_isempty_false(flag: Ptr[u32], i: int) -> void:
flag[i >> 4] &= u32(~(2 << ((i & 0xF) << 1)))
def __ac_set_isboth_false(flag: Ptr[u32], i: int) -> void:
flag[i >> 4] &= u32(~(3 << ((i & 0xF) << 1)))
def __ac_set_isdel_true(flag: Ptr[u32], i: int) -> void:
flag[i >> 4] |= u32(1 << ((i & 0xF) << 1))
def __ac_fsize(m) -> int:
return 1 if m < 16 else m >> 4