persistable static class SynchronizedSortedSet extends SynchronizedSet implements SortedSet { @java.io.Serial private static final long serialVersionUID = 8695801310862127406L; @SuppressWarnings("serial") // Conditionally serializable /*private final*/ SortedSet ss; SynchronizedSortedSet(SortedSet s) { super(s); ss = s; } SynchronizedSortedSet(SortedSet s, Object mutex) { super(s, mutex); ss = s; } public Comparator comparator() { synchronized (mutex) {return ss.comparator();} } public SortedSet subSet(E fromElement, E toElement) { synchronized (mutex) { return new SynchronizedSortedSet<>( ss.subSet(fromElement, toElement), mutex); } } public SortedSet headSet(E toElement) { synchronized (mutex) { return new SynchronizedSortedSet<>(ss.headSet(toElement), mutex); } } public SortedSet tailSet(E fromElement) { synchronized (mutex) { return new SynchronizedSortedSet<>(ss.tailSet(fromElement),mutex); } } public E first() { synchronized (mutex) {return ss.first();} } public E last() { synchronized (mutex) {return ss.last();} } }