About the string hash

Because :sk: only has a list container…
I wanted to create a hash map container.
(Later, when I have time)

I can’t see a function that accesses chars one by one in the string class for the hash function.(ex : at(index))
Can I use string.as_crs32 instead of creating a string hash function?
(Is this function fast enough?)

uint32_t AChecksum::generate_crc32_cstr(
  const char * cstr_p,
  uint32_t     length,  // = ALength_calculate
  uint32_t     prev_crc // = 0
  uint32_t  crc        = ~prev_crc;
  uint8_t * byte_p     = (uint8_t *)cstr_p;
  uint8_t * byte_end_p = byte_p + ((length == ALength_calculate) ? uint32_t(::strlen(cstr_p)) : length);

  while (byte_p < byte_end_p)
    crc = s_table_crc32[(crc ^ uint32_t(*byte_p++)) & 0xff] ^ (crc >> 8);

  return ~crc;

I think I found the C++ code…
It feels similar to a normal hash.

1 Like

That should work, though I’d probably create most if not all of a new collection in C++ for speed and then just hook it up to Sk.