void printDiamonde2cpa(in uint N)
{
size_t N2 = N/2;
char p[] = uninitializedArray!(char[])(N2+N);
p[0..N2] = ' ';
p[N2..$] = '*';
char nl[] = uninitializedArray!(char[])(1);
nl[] = '\n';
char[][] wc = minimallyInitializedArray!(char[][])(N);
auto w = appender!(char[])();
foreach(n, ref elem; taskPool.parallel(wc[0..N2+1],100)){
elem = p[n .. N2+2*n+1];
}
foreach (rn, ref elem ; taskPool.parallel(wc[0..N2],100)){
int n = N2 - rn - 1;
elem = p[n .. N2+2*n+1];
}
auto wj = join(wc,nl);
w.put(wj);
writeln(w.data);
}
This is a first attempt at using parallel, but no improvement in
speed on a corei7. It is about 3x slower than the prior
versions. Probably the join was not a good idea. Also, no
foreach_reverse for the parallel, so it requires extra
calculations for the reverse index.
- Re: Functi... Jay Norwood
- Re: Function to pri... Luís.Marques
- Re: Function to print a diamond shap... bearophile
- Re: Function to print a diamond... Jay Norwood
- Re: Function to print a dia... Jay Norwood
- Re: Function to print a dia... monarch_dodra
- Re: Function to print a... Jay Norwood
- Re: Function to pri... Jay Norwood
- Re: Function t... monarch_dodra
- Re: Functi... Jay Norwood
- Re: Functi... Jay Norwood
- Re: Functi... Jay Norwood
- Re: Functi... Jay Norwood
- Re: Function to print a... Jay Norwood via Digitalmars-d-learn
- Re: Function to pri... monarch_dodra via Digitalmars-d-learn
- Re: Function t... Jay Norwood via Digitalmars-d-learn
- Re: Functi... Jay Norwood via Digitalmars-d-learn
- Re: Functi... monarch_dodra via Digitalmars-d-learn
- Re: Functi... Jay Norwood via Digitalmars-d-learn
- Re: Functi... monarch_dodra via Digitalmars-d-learn
- Re: Function to print a diamond... bearophile
