SplitHistory implements Comparable<SplitHistory>, Serializable { @Override public int compareTo(SplitHistory history) { int ts = size(); int ps = history.size(); for (int i = 0; i < Math.min(ts, ps); i++) { SplitHistoryEntry tn = entries.get(i); SplitHistoryEntry pn = history.entries.get(i); if (tn.getIndex() != pn.getIndex()) { return tn.getIndex() - pn.getIndex(); } } return ts - ps; } SplitHistory();  SplitHistory(int initialCapacity); private  SplitHistory(boolean addRoot); private  SplitHistory(int initialCapacity, boolean addRoot); int size(); List<SplitHistoryEntry> entries(); int[] indexPath(); String indexPathString(); SplitHistory[] split(int num); SplitHistory split(int index, boolean last); @Override int compareTo(SplitHistory history); boolean isPredecessor(SplitHistory history); boolean isSuccessor(SplitHistory history); boolean isFirstUpTo(int level); boolean isLastUpTo(int level); boolean isFirst(); boolean isLast(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static SplitHistory parse(String history); static final SplitHistory ROOT; }
@Test public void testCompareTo() { String p1 = "[(0/1),(0/3),(0/2)]"; String p2 = "[(0/1),(0/3),(0/2)]"; assertTrue(SplitHistory.parse(p2).compareTo(SplitHistory.parse(p1)) == 0); p1 = "[(0/1),(0/3),(0/2)]"; p2 = "[(0/1),(0/3),(1/2)]"; assertTrue(SplitHistory.parse(p1).compareTo(SplitHistory.parse(p2)) < 0); assertTrue(SplitHistory.parse(p2).compareTo(SplitHistory.parse(p1)) > 0); p1 = "[(0/1),(0/3)]"; p2 = "[(0/1),(0/3),(1/2)]"; assertTrue(SplitHistory.parse(p1).compareTo(SplitHistory.parse(p2)) < 0); assertTrue(SplitHistory.parse(p2).compareTo(SplitHistory.parse(p1)) > 0); p1 = "[(0/1),(0/3),(0/2)]"; p2 = "[(0/1),(1/3),(0/2)]"; assertTrue(SplitHistory.parse(p1).compareTo(SplitHistory.parse(p2)) < 0); assertTrue(SplitHistory.parse(p2).compareTo(SplitHistory.parse(p1)) > 0); }