RevisionVector implements Iterable<Revision>, Comparable<RevisionVector>, CacheValue { public RevisionVector difference(RevisionVector vector) { List<Revision> diff = newArrayListWithCapacity(revisions.length); PeekingIterator<Revision> it = peekingIterator(vector.iterator()); for (Revision r : revisions) { Revision other = peekRevision(it, r.getClusterId()); if (!r.equals(other)) { diff.add(r); } } return new RevisionVector(toArray(diff, Revision.class), false, false); } 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 difference() { RevisionVector rv1 = new RevisionVector(); RevisionVector rv2 = new RevisionVector(); assertEquals(new RevisionVector(), rv1.difference(rv2)); Revision r11 = new Revision(1, 0, 1); rv1 = rv1.update(r11); assertEquals(new RevisionVector(r11), rv1.difference(rv2)); assertEquals(new RevisionVector(), rv2.difference(rv1)); rv2 = rv2.update(r11); assertEquals(new RevisionVector(), rv1.difference(rv2)); assertEquals(new RevisionVector(), rv2.difference(rv1)); Revision r12 = new Revision(1, 0, 2); rv1 = rv1.update(r12); assertEquals(new RevisionVector(r12), rv1.difference(rv2)); assertEquals(new RevisionVector(), rv2.difference(rv1)); Revision r22 = new Revision(2, 0, 2); rv2 = rv2.update(r22); assertEquals(new RevisionVector(r12), rv1.difference(rv2)); assertEquals(new RevisionVector(r22), rv2.difference(rv1)); Revision r21 = new Revision(2, 0, 1); rv1 = rv1.update(r21); assertEquals(new RevisionVector(r21, r12), rv1.difference(rv2)); assertEquals(new RevisionVector(r11, r22), rv2.difference(rv1)); }