Browse Source

ordered set

David Sehnal 7 years ago
parent
commit
b42b10f680
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/mol-base/collections/ordered-set.ts

+ 2 - 1
src/mol-base/collections/ordered-set.ts

@@ -428,7 +428,8 @@ function substractRR(a: Range, b: Range) {
     if (isRangeSubset(a, b)) {
         // this splits the interval into two, gotta represent it as a set.
         const l = _sRB.fst - _sRA.fst, r = _sRA.snd - _sRB.snd;
-        // TODO: check if l === 0 || r === 0 ==> result would be a range
+        if (l <= 0) return OrderedSet.ofRange(_sRB.snd + 1, _sRB.snd + r);
+        if (r <= 0) return OrderedSet.ofRange(_sRA.fst, _sRA.fst + l - 1);
         const ret = new Int32Array(l + r);
         let offset = 0;
         for (let i = 0; i < l; i++) ret[offset++] = _sRA.fst + i;