tuple of ranges - findSplit

Dmitry Olshansky dmitry.olsh at gmail.com
Thu May 24 03:21:05 PDT 2012


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


More information about the Digitalmars-d mailing list