How can this best be done?

bearophile bearophileHUGS at lycos.com
Mon Oct 14 17:46:11 PDT 2013


Johan Fjeldtvedt:

> https://gist.github.com/Jaffe-/6983847

I think something like that should go in Phobos. But I'd like 
some improvements:
- Perhaps you can use a syntax similar to the tuples one:
  ParallelStaticArray!(int,"field1", string,"field2", 
double,"field3", 5) test1;
  auto test2 = ParallelDynArray!(int,"field1", string,"field2", 
double,"field3")(5);
A version is meant to have fixed size and the other is more like 
a dynamic array.
- I think it's useful to have a syntax to "group" fields, so they 
are represented as parallel arrays of smaller structs instead of 
just parallel arrays. This is useful if you have to read/write 
fields in a coherent way.
- I think this data structure should have a basic capability to 
analyse its usage patterns (this feature is off on default and 
can be switched on with a template argument). This is useful to 
tune the grouping of fields.
- Iteration is a bit tricky. Probably it's a good idea to iterate 
only on one group at a time.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list