### Question:
DocumentSet implements Iterable<Document> { public List<Document> toList() { List<Document> documents = new ArrayList<>(size()); for (Document document : this) { documents.add(document); } return documents; } private  DocumentSet(
      ImmutableSortedMap<DocumentKey, Document> keyIndex, ImmutableSortedSet<Document> sortedSet); static DocumentSet emptySet(final Comparator<Document> comparator); int size(); boolean isEmpty(); boolean contains(DocumentKey key); @Nullable Document getDocument(DocumentKey key); @Nullable Document getFirstDocument(); @Nullable Document getLastDocument(); @Nullable Document getPredecessor(DocumentKey key); int indexOf(DocumentKey key); DocumentSet add(Document document); DocumentSet remove(DocumentKey key); List<Document> toList(); @Override @NonNull Iterator<Document> iterator(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testKeepsDocumentsInTheRightOrder() { DocumentSet set = docSet(TEST_COMPARATOR, DOC1, DOC2, DOC3); assertEquals(Arrays.asList(DOC3, DOC1, DOC2), set.toList()); }
@Test public void testAddsDocsWithEqualComparisonValues() { Document doc1 = doc("docs/1", 0, map("sort", 2)); Document doc2 = doc("docs/2", 0, map("sort", 2)); DocumentSet set = docSet(TEST_COMPARATOR, doc1, doc2); assertEquals(Arrays.asList(doc1, doc2), set.toList()); }