Create variable for RedBlackTree range

Gerald gerald.b.nunn at gmail.com
Sat Apr 28 16:36:41 UTC 2018


What is the appropriate way to create a variable for the range 
returned by RedBlackTree lowerBound and upperBound. For example, 
given this code:

```
RedBlackTree!long promptPosition = redBlackTree!long();

long row = to!long(vte.getVadjustment().getValue());
RBRange!(RBNode!long*) range;
if (direction < 0) {
     range = promptPosition.lowerBound(row);
     if (range.empty) result = lower;
     else result = range.back;
} else {
     range = promptPosition.upperBound(row);
     if (range.empty) result = upper;
     else result = range.front();
}
if (result >= lower) {
     vte.getVadjustment.setValue(to!double(result));
} else {
     promptPosition.remove(range);
}
```

The second line where I declare the range variable as 
RBRange!(RBNode!long*) the compiler complains with the following 
warning:

Deprecation: std.container.rbtree.RBRange(N) is not visible from 
module terminal

Which makes sense since RBRange is a private struct. However I 
cannot use the normal range interfaces here either (ForwardRange, 
BiDirectionalRange, etc) since it complains about RBRange not 
being able to cast to them.


More information about the Digitalmars-d-learn mailing list