From ff9c14defbd2eb8dd497788b0c443512cbcd8510 Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Thu, 12 Jul 2018 11:25:57 +0200 Subject: [PATCH] Fix OrderedSet areInterseting array/interval --- src/mol-data/int/_spec/ordered-set.spec.ts | 3 +++ src/mol-data/int/impl/ordered-set.ts | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mol-data/int/_spec/ordered-set.spec.ts b/src/mol-data/int/_spec/ordered-set.spec.ts index a8f2a5d10..e39cb3c09 100644 --- a/src/mol-data/int/_spec/ordered-set.spec.ts +++ b/src/mol-data/int/_spec/ordered-set.spec.ts @@ -56,6 +56,9 @@ describe('ordered set', () => { expect(OrderedSet.areIntersecting(Interval.ofRange(4, 5), arr12369)).toBe(false); expect(OrderedSet.areIntersecting(Interval.ofRange(7, 8), arr12369)).toBe(false); + + expect(OrderedSet.areIntersecting(Interval.ofRange(6, 6), arr12369)).toBe(true); + expect(OrderedSet.areIntersecting(Interval.ofRange(3, 4), OrderedSet.ofSortedArray([0, 1, 10]))).toBe(false); }); it('isSubset', () => { diff --git a/src/mol-data/int/impl/ordered-set.ts b/src/mol-data/int/impl/ordered-set.ts index 6031729da..e6b3bec70 100644 --- a/src/mol-data/int/impl/ordered-set.ts +++ b/src/mol-data/int/impl/ordered-set.ts @@ -99,10 +99,7 @@ export function subtract(a: OrderedSetImpl, b: OrderedSetImpl) { function areEqualIS(a: I, b: S) { return I.size(a) === S.size(b) && I.start(a) === S.start(b) && I.end(a) === S.end(b); } function areIntersectingSI(a: S, b: I) { - if (S.size(a) === 0 || I.size(b) === 0) return false - const predAMinB = S.findPredecessorIndex(a, I.min(b)) - const predAMaxB = S.findPredecessorIndex(a, I.max(b)) - return predAMinB !== predAMaxB + return a.length !== 0 && I.size(S.findRange(a, I.min(b), I.max(b))) !== 0; } function isSubsetSI(a: S, b: I) { -- GitLab