Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-foundation

Source of release 0.6.1

0.6.1 / src / ak / types_traits.lucb

#==============================================================================================
#
#   types_traits - hash traits of the key types of HashMap/HashTable instantiations
#
#   DESCRIPTION:
#       Generated by the skeleton generator (DESIGN.md ยง2.6): one declaration per distinct
#       instantiation the phase-1 declarations use, at donor commit 47c82b38d0.
#
#==============================================================================================

## AK::Traits<FlyString>: AK's hash and equality for the key type.
pub struct FlyStringTraits: Traits[FlyString]:
    var empty_: u8

    func hash_of(key: const FlyString*) -> u32: return fly_string_hash(key)

    func equals(a: const FlyString*, b: const FlyString*) -> bool: return fly_string_eq_fly_string(a, b)

## AK::Traits<i32>: AK's hash and equality for the key type.
pub struct I32Traits: Traits[i32]:
    var empty_: u8

    func hash_of(key: const i32*) -> u32: return u32_hash((u32)*key)

    func equals(a: const i32*, b: const i32*) -> bool: return *a == *b

## AK::Traits<i64>: AK's hash and equality for the key type.
pub struct I64Traits: Traits[i64]:
    var empty_: u8

    func hash_of(key: const i64*) -> u32: return u64_hash((u64)*key)

    func equals(a: const i64*, b: const i64*) -> bool: return *a == *b

## AK::Traits<String>: AK's hash and equality for the key type.
pub struct StringTraits: Traits[String]:
    var empty_: u8

    func hash_of(key: const String*) -> u32: return string_hash_value(key)

    func equals(a: const String*, b: const String*) -> bool: return string_equals(a, b)

## Concepts::HashCompatible<String, StringView>: looking a String table up by a StringView. A
## StringView hashes as the String with the same bytes, and `String == StringView` compares
## the bytes (added at integration for web_unicode's available-locale table).
pub struct StringStringViewTraits: HashCompatibleTraits[String, StringView]:
    var empty_: u8

    func hash_of(key: const StringView*) -> u32: return string_view_hash(key)

    func equals(entry: const String*, key: const StringView*) -> bool:
        let view = string_bytes_as_string_view(entry)
        return string_view_eq_string_view(&view, *key)

## AK::Traits<u32>: AK's hash and equality for the key type.
pub struct U32Traits: Traits[u32]:
    var empty_: u8

    func hash_of(key: const u32*) -> u32: return u32_hash(*key)

    func equals(a: const u32*, b: const u32*) -> bool: return *a == *b

## AK::Traits<u64>: AK's hash and equality for the key type.
pub struct U64Traits: Traits[u64]:
    var empty_: u8

    func hash_of(key: const u64*) -> u32: return u64_hash(*key)

    func equals(a: const u64*, b: const u64*) -> bool: return *a == *b

## AK::Traits<Utf16String>: AK's hash and equality for the key type.
pub struct Utf16StringTraits: Traits[Utf16String]:
    var empty_: u8

    func hash_of(key: const Utf16String*) -> u32: return utf16_string_base_hash(&key.utf16_string_base)

    func equals(a: const Utf16String*, b: const Utf16String*) -> bool: return utf16_string_base_eq_utf16_string_base(&a.utf16_string_base, &b.utf16_string_base)