Store multiple identical objects in a key:ed datastructure?

Tove tove at fransson.se
Fri Nov 1 10:29:54 UTC 2019


Consider a complex key that is a combination of multiple 
variables.

struct key
{
   int    foo = 1;
   string bar = "joy";
   string baz = "huzza";
}

The value is a very large object.

struct value
{
   int[4096] payload;
}

There are 10.000s of different keys.
But typically only ~10 different values.

My first idea was to have an array/set of unique value instances 
and store only the index to the array in the key:ed data 
structure, this way it's possible to reallocate and extend the 
array.

Is there an idiomatic way to solve this in D? Or should I just 
get my hands dirty and do the brute force implementation of the 
above idea?



More information about the Digitalmars-d-learn mailing list