From b42b10f680240712eb16dc255f097069eaeb8c81 Mon Sep 17 00:00:00 2001
From: David Sehnal <david.sehnal@gmail.com>
Date: Wed, 25 Oct 2017 23:12:43 +0200
Subject: [PATCH] ordered set

---
 src/mol-base/collections/ordered-set.ts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mol-base/collections/ordered-set.ts b/src/mol-base/collections/ordered-set.ts
index c51ba055a..fea561f31 100644
--- a/src/mol-base/collections/ordered-set.ts
+++ b/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;
-- 
GitLab