On Saturday, 15 February 2014 at 09:51:57 UTC, Uranuz wrote:
I have read doc for std.range and std.algorithm, but I have not found how I could add new value to SortedRange. What I want is to sort some array of structs by one of it's fields using custom predicate and save this SortedRange somewhere. But also I need to be able to append new elements into array and keep it sorted and using advantages of sorted data structure to for doing it quick.

Is it possible to do it in current implementation of SortedRange. If not what workarounds would you advise?

The range concept does not include any notion of growing. It's kind of messy, you have to grow the original:

---
T x = ...; // Insert x into...
T[] c = ...; // ...this sorted slice

auto pivot = c.assumeSorted().lowerBound(x).length;
c.insertInPlace(pivot, x);
---

For non-slice containers, use the `insertBefore` primitive (see std.container).

Reply via email to