← Back to context

Comment by andsoitis

14 hours ago

> how would you represent a hash table where the values are strings and at random, the program inserts or deletes a random string?

Goose has a built-in generic hash table called dictionary<K, V>, provided by its standard library.

https://aardappel.github.io/goose/docs/stdlib.html#dictionar...

From the link

> Keys and values are fixed-size

so not quite what I'm looking for

  • You can store the strings separately and have the dictionary hold references to them.

    Conceptually:

    dictionary<i64, StringReference>

                 |
    
                 +----> "hello"
    
                 +----> "a much longer string"
    
                 +----> "x"

    • Isn’t this just re-inventing the index arena pattern, which nullifies much of the benefit over rust?

      > Goose code holds typed references where the equivalent Rust holds u32 indices into an arena — and it is where a good share of the benchmark wins come from.

      1 reply →