### Question:
FoldedTreeSet implements SortedSet<E> { @Override public Object[] toArray() { Object[] objects = new Object[size]; if (!isEmpty()) { int pos = 0; for (Node<E> node = root.getLeftMostNode(); node != null; pos += node.size, node = node.next) { System.arraycopy(node.entries, node.leftIndex, objects, pos, node.size); } } return objects; } FoldedTreeSet();  FoldedTreeSet(Comparator<E> comparator); @Override Comparator<? super E> comparator(); @Override SortedSet<E> subSet(E fromElement, E toElement); @Override SortedSet<E> headSet(E toElement); @Override SortedSet<E> tailSet(E fromElement); @Override E first(); @Override E last(); @Override int size(); @Override boolean isEmpty(); E get(Object obj, Comparator<?> cmp); E get(E entry); @Override @SuppressWarnings("unchecked") boolean contains(Object obj); @Override Iterator<E> iterator(); @Override Object[] toArray(); @Override @SuppressWarnings("unchecked") T[] toArray(T[] a); E addOrReplace(E entry); @Override boolean add(E entry); boolean addSortedLast(E entry); E removeAndGet(Object obj, Comparator<?> cmp); E removeAndGet(Object obj); boolean remove(Object obj, Comparator<?> cmp); @Override boolean remove(Object obj); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends E> c); @Override boolean retainAll(Collection<?> c); @Override boolean removeAll(Collection<?> c); @Override void clear(); double fillRatio(); boolean compact(long timeout);  }### Answer:
@Test public void testToArray() { FoldedTreeSet<Integer> tree = new FoldedTreeSet<>(); ArrayList<Integer> list = new ArrayList<>(256); for (int i = 0; i < 256; i++) { list.add(1024 + i); } tree.addAll(list); assertArrayEquals(list.toArray(), tree.toArray()); }