almost complete implementation of IntervalSet