Structure of Arrays vs Array of Structures
a11e99z
black80 at bk.ru
Mon Aug 26 10:59:43 UTC 2019
On Monday, 26 August 2019 at 09:58:30 UTC, Per Nordlöw wrote:
> On Monday, 26 August 2019 at 09:54:30 UTC, Per Nordlöw wrote:
>> I have made some significant optimizations with regards to
>> compilation performance at
>>
>> https://github.com/nordlow/phobos-next/blob/master/src/soa.d
>
> What is the preferred way to implement to support foreach over
> `x` in
>
> struct S { int i; float f; }
> auto x = SOA!S();
> foreach (S; x[])
> {
> }
>
> ?
>
> Implement `opSlice` that returns a SOA.Range type?
1) not sure about opSlice cuz user can allocate every time when
he need S[..] from SOA.
easy call for user but its too expensive op.
maybe better to define global array( T )( SOA!T {opt: int beg,
int end}) that returns array.
> x.array or array( x ) or x.array( 10, 20)
looks like DRT that means "some range to newly allocated
array". and SOA to S is some calculated range - need construct
each element.
2) x.items returns SOA.Range
More information about the Digitalmars-d-learn
mailing list