Convert array to tupled array easily?
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Sep 14 17:30:21 PDT 2015
On 09/14/2015 04:23 PM, Prudence wrote:
> To solve that problem, I'd like to try and turn the Value into Tuples of
> the Value and the address of the SingleStore wrapper(which should be
> unique).
>
> e.g.,
> public Tuple!(TValue, void*)[][TKey] Store;
After changing that, I methodically dealt with compilation errors. A
total of 6 changes were sufficient:
$ diff before.d after.d
24c24
< public TValue[][TKey] Store;
---
> public Tuple!(TValue, void*)[][TKey] Store;
36c36
< if (c == Value)
---
> if (c[0] == Value)
39c39
< Store[Key][i] = null; // Set to null to release
any references if necessary
---
> Store[Key][i][1] = null; // Set to null to
release any references if necessary
58c58
< public static auto New(TKey k, TValue v, ref TValue[][TKey] s)
---
> public static auto New(TKey k, TValue v, ref Tuple!(TValue,
void*)[][TKey] s)
77c77
< public static TValue[][TKey] Store;
---
> public static Tuple!(TValue, void*)[][TKey] Store;
81c81
< (Store[k]) ~= v;
---
> (Store[k]) ~= tuple(v, cast(void*)null);
Ali
More information about the Digitalmars-d-learn
mailing list