RevisionVector implements Iterable<Revision>, Comparable<RevisionVector>, CacheValue { @Override public int compareTo(@NotNull RevisionVector other) { Iterator<Revision> it = other.iterator(); for (Revision r : revisions) { if (!it.hasNext()) { return 1; } Revision otherRev = it.next(); int cmp = -Ints.compare(r.getClusterId(), otherRev.getClusterId()); if (cmp != 0) { return cmp; } cmp = r.compareTo(otherRev); if (cmp != 0) { return cmp; } } return it.hasNext() ? -1 : 0; } private  RevisionVector(@NotNull Revision[] revisions,
                           boolean checkUniqueClusterIds,
                           boolean sort);  RevisionVector(@NotNull Revision... revisions);  RevisionVector(@NotNull Iterable<Revision> revisions);  RevisionVector(@NotNull Set<Revision> revisions); RevisionVector update(@NotNull Revision revision); RevisionVector remove(int clusterId); RevisionVector pmin(@NotNull RevisionVector vector); RevisionVector pmax(@NotNull RevisionVector vector); RevisionVector difference(RevisionVector vector); boolean isRevisionNewer(@NotNull Revision revision); boolean isBranch(); @NotNull Revision getBranchRevision(); Revision getRevision(int clusterId); String asString(); StringBuilder toStringBuilder(StringBuilder sb); static RevisionVector fromString(String s); RevisionVector asTrunkRevision(); RevisionVector asBranchRevision(int clusterId); int getDimensions(); @Override int getMemory(); @Override int compareTo(@NotNull RevisionVector other); @Override Iterator<Revision> iterator(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void compareTo() { RevisionVector rv1 = new RevisionVector(); RevisionVector rv2 = new RevisionVector(); assertEquals(0, rv1.compareTo(rv2)); Revision r11 = new Revision(1, 0, 1); rv1 = rv1.update(r11); assertTrue(rv1.compareTo(rv2) > 0); assertTrue(rv2.compareTo(rv1) < 0); Revision r12 = new Revision(1, 0, 2); rv2 = rv2.update(r12); assertTrue(rv1.compareTo(rv2) > 0); assertTrue(rv2.compareTo(rv1) < 0); rv2 = rv2.update(r11); assertTrue(rv1.compareTo(rv2) < 0); assertTrue(rv2.compareTo(rv1) > 0); rv1 = rv1.update(r12); assertEquals(0, rv1.compareTo(rv2)); assertEquals(0, rv2.compareTo(rv1)); Revision r22 = new Revision(2, 0, 2); rv2 = rv2.update(r22); assertTrue(rv1.compareTo(rv2) < 0); assertTrue(rv2.compareTo(rv1) > 0); Revision rb22 = r22.asBranchRevision(); rv1 = rv1.update(rb22); assertTrue(rv1.compareTo(rv2) < 0); assertTrue(rv2.compareTo(rv1) > 0); }