May 23, 2012 tuple of ranges - findSplit | ||||
|---|---|---|---|---|
| ||||
I'm currently designing an interface, which conceptually is similar to findSplit... so I decided to peek at/learn from Phobos...
"findSplit returns a tuple result containing three ranges"
tuple(haystack[0 .. pos1],haystack[pos1 .. pos2], haystack[pos2 .. haystack.length]);
As one easiliy can spot, pos1 and pos2 occurs twice... in isolated cases it doesn't matter, but in my case I was planning to generate a number of these.
Hmmm... just wondering, did anyone already design/implement a pretty/efficient interface ontop of a structure similar to below?
struct
{
uint r0;
union
{
uint r1
uint r2
}
union
{
uint r3
uint r4
}
uint r5;
}
| ||||
May 24, 2012 Re: tuple of ranges - findSplit | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Tove | On 24.05.2012 1:56, Tove wrote: > I'm currently designing an interface, which conceptually is similar to > findSplit... so I decided to peek at/learn from Phobos... > > "findSplit returns a tuple result containing three ranges" > > tuple(haystack[0 .. pos1],haystack[pos1 .. pos2], haystack[pos2 .. > haystack.length]); > > As one easiliy can spot, pos1 and pos2 occurs twice... in isolated cases > it doesn't matter, but in my case I was planning to generate a number of > these. > > Hmmm... just wondering, did anyone already design/implement a > pretty/efficient interface ontop of a structure similar to below? > > struct > { > uint r0; > union > { > uint r1 > uint r2 > } > union > { > uint r3 > uint r4 > } > uint r5; > } > Something like this could be made to work if it looks like Tuple of 3 _slices_ in every other aspect. Saving 2 words is not bad at all ;) -- Dmitry Olshansky | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply