{
List<SubList> sublists = new ArrayList<SubList>();
+ if (ranges.isEmpty())
+ {
+ return sublists;
+ }
+
int listStartIndex = 0;
long lastEndPos = Long.MAX_VALUE;
{
NCNode<T> subrange = subranges.get(j);
- if (end < subrange.getStart() && !overlapping && !enclosing)
+ if (end < subrange.getBegin() && !overlapping && !enclosing)
{
/*
* new entry lies between subranges j-1 j
return true;
}
- if (subrange.getStart() <= start && subrange.getEnd() >= end)
+ if (subrange.getBegin() <= start && subrange.getEnd() >= end)
{
/*
* push new entry inside this subrange as it encloses it
return true;
}
- if (start <= subrange.getStart())
+ if (start <= subrange.getBegin())
{
if (end >= subrange.getEnd())
{
for (int i = candidateIndex; i < subranges.size(); i++)
{
NCNode<T> candidate = subranges.get(i);
- if (candidate.getStart() > to)
+ if (candidate.getBegin() > to)
{
/*
* we are past the end of our target range
for (int i = candidateIndex; i < subranges.size(); i++)
{
NCNode<T> candidate = subranges.get(i);
- if (candidate.getStart() > to)
+ if (candidate.getBegin() > to)
{
/*
* we are past the end of our target range
}
/**
- * Returns a string representation of the data where containment is shown bgy
+ * Returns a string representation of the data where containment is shown by
* indentation on new lines
*
* @return
int offset = 0;
int indent = 2;
prettyPrint(sb, offset, indent);
+ sb.append(System.lineSeparator());
return sb.toString();
}
int lastStart = start;
for (NCNode<T> subrange : subranges)
{
- if (subrange.getStart() < lastStart)
+ if (subrange.getBegin() < lastStart)
{
System.err.println("error in NCList: range " + subrange.toString()
+ " starts before " + lastStart);
+ " ends after " + end);
return false;
}
- lastStart = subrange.getStart();
+ lastStart = subrange.getBegin();
if (!subrange.isValid())
{
*/
public int getStart()
{
- return subranges.isEmpty() ? 0 : subranges.get(0).getStart();
+ return subranges.isEmpty() ? 0 : subranges.get(0).getBegin();
}
/**
{
/*
* if the subrange is rooted on this entry, promote its
- * subregions (if any) to replace the subrange here
+ * subregions (if any) to replace the subrange here;
+ * NB have to resort subranges after doing this since e.g.
+ * [10-30 [12-20 [16-18], 13-19]]
+ * after deleting 12-20, 16-18 is promoted to sibling of 13-19
+ * but should follow it in the list of subranges of 10-30
*/
subranges.remove(i);
if (subRegions != null)
{
subranges.addAll(i, subRegions.subranges);
+ Collections.sort(subranges, intervalSorter);
}
size--;
return true;
}
return false;
}
-
- /**
- * Answers true if this contains no ranges
- *
- * @return
- */
- public boolean isEmpty()
- {
- return getSize() == 0;
- }
-
- /**
- * Answer the list of subranges held in this NCList
- *
- * @return
- */
- List<NCNode<T>> getSubregions()
- {
- return subranges;
- }
}