- /*
- * fail if we detect feature enclosure - of the new feature by
- * the one preceding it, or of the next feature by the new one
- */
- if (insertPosition > 0)
+ /*
+ * insert into list sorted by start (first contact position):
+ * binary search the sorted list to find the insertion point
+ */
+ int insertAt = BinarySearcher.findFirst(contactFeatureStarts, true,
+ Compare.GE, feature.begin);
+ contactFeatureStarts.add(insertAt, feature);
+ /*
+ * insert into list sorted by end (second contact position):
+ * binary search the sorted list to find the insertion point
+ */
+ contactFeatureEnds.add(findFirstEnd(contactFeatureEnds, feature.end),
+ feature);
+
+ return true;
+ }
+
+ /**
+ * Adds one sequence feature to the store, and returns true, unless the
+ * feature is already contained in the store, in which case this method
+ * returns false. Containment is determined by SequenceFeature.equals()
+ * comparison.
+ *
+ * @param feature
+ */
+ public boolean addFeature(SequenceFeature feature)
+ {
+ if (feature.isContactFeature())
+ {
+ if (containsContactFeature(feature))