From 8a5b4942a0625dd64429291729d89438fccfd804 Mon Sep 17 00:00:00 2001 From: hansonr Date: Sat, 3 Aug 2019 00:07:15 -0500 Subject: [PATCH] JavaDoc comments; minor code clean-up --- src/jalview/datamodel/features/FeatureStore.java | 35 +++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/jalview/datamodel/features/FeatureStore.java b/src/jalview/datamodel/features/FeatureStore.java index e60aec5..716eb04 100644 --- a/src/jalview/datamodel/features/FeatureStore.java +++ b/src/jalview/datamodel/features/FeatureStore.java @@ -965,6 +965,10 @@ public class FeatureStore } /** + * Run through the sorted sequence array once, building the containedBy linked + * list references. Does a check first to make sure there is actually + * something out there that is overlapping. A null for sf.containedBy means + * there are no overlaps for this feature. * * @param intervals */ @@ -977,24 +981,25 @@ public class FeatureStore int maxEnd = intervals[0].end; for (int i = 1, n = intervals.length; i < n; i++) { - SequenceFeature ithis = intervals[i]; - if (ithis.begin <= maxEnd) + SequenceFeature sf = intervals[i]; + if (sf.begin <= maxEnd) { - ithis.containedBy = getContainedBy(intervals[i - 1], ithis); + sf.containedBy = getContainedBy(intervals[i - 1], sf); } - if (ithis.end > maxEnd) + if (sf.end > maxEnd) { - maxEnd = ithis.end; + maxEnd = sf.end; } } } /** - * Since we are traversing the sorted feature array, all elements prior to the - * one we are working on have been fully linked. All we are doing is following - * those links until we find the first array feature with a containedBy - * element that has an end >= our begin point. It is generally a very short - * list -- maybe one or two depths. But it might be more than that. + * Since we are traversing the sorted feature array in a forward direction, + * all elements prior to the one we are working on have been fully linked. All + * we are doing is following those links until we find the first array feature + * with a containedBy element that has an end >= our begin point. It is + * generally a very short list -- maybe one or two depths. But it might be + * more than that. * * @param sf * @param sf0 @@ -1017,7 +1022,7 @@ public class FeatureStore return null; } - // Searching for overlapping features at a given position: + // search-stage methods /** * Binary search for contact start or end at a given (Overview) position. @@ -1122,7 +1127,10 @@ public class FeatureStore /** * A binary search identical to the one used for contact start/end, but here - * we return the feature itself. + * we return the feature itself. Unlike Collection.BinarySearch, all we have + * to be is close, not exact, and we make sure if there is a string of + * identical starts, then we slide to the end so that we can check all of + * them. * * @param l * @param pos @@ -1150,8 +1158,7 @@ public class FeatureStore { ; } - mid--; - return l[mid]; + return l[--mid]; } } // -1 here? -- 1.7.10.2