+ * Add a contact feature to the lists that hold them ordered by start (first
+ * contact) and by end (second contact) position, ensuring the lists remain
+ * ordered, and returns true. This method allows duplicate features to be
+ * added, so test before calling to avoid this.
+ *
+ * @param feature
+ * @return
+ */
+ @Override
+ protected synchronized boolean addContactFeature(SequenceFeature feature)
+ {
+ if (contactFeatureStarts == null)
+ {
+ contactFeatureStarts = new ArrayList<>();
+ contactFeatureEnds = new ArrayList<>();
+ }
+
+ /*
+ * insert into list sorted by start (first contact position):
+ * binary search the sorted list to find the insertion point
+ */
+ int insertPosition = findFirstBeginStatic(contactFeatureStarts,
+ feature.getBegin());
+ contactFeatureStarts.add(insertPosition, feature);
+
+ /*
+ * insert into list sorted by end (second contact position):
+ * binary search the sorted list to find the insertion point
+ */
+ insertPosition = findFirstEndStatic(contactFeatureEnds,
+ feature.getEnd());
+ contactFeatureEnds.add(insertPosition, feature);
+
+ return true;
+ }
+
+ /**