FoldedTreeSet implements SortedSet<E> { @Override public E first() { if (!isEmpty()) { Node<E> node = root.getLeftMostNode(); return node.entries[node.leftIndex]; } return null; } 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);  }
@Test public void testFirst() { FoldedTreeSet<Integer> tree = new FoldedTreeSet<>(); for (int i = 0; i < 256; i++) { tree.add(1024 + i); assertEquals(1024, tree.first().intValue()); } for (int i = 1; i < 256; i++) { tree.remove(1024 + i); assertEquals(1024, tree.first().intValue()); } }