Sorted ranges in combined sorted order?

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 20 13:49:38 PDT 2016


Given a range of ranges where individual ranges are already sorted, is 
there anything in Phobos that can visit the combined range in sorted order?

Although the range elements are not necessarily arrays, e.g.

     [ [ 3, 10, 20 ]
       [ 1, 2, 7 ]
       [ 5, 6 ] ]

The elements should appear without any copying as

     [ 1, 2, 3, 5, 6, 7, 10, 20 ]

The outer range may be unsorted but luckily it has very few elements so 
a linear search should be fine.

Ali


More information about the Digitalmars-d-learn mailing list