persistable static class SynchronizedNavigableSet extends SynchronizedSortedSet implements NavigableSet { @java.io.Serial private static final long serialVersionUID = -5505529816273629798L; @SuppressWarnings("serial") // Conditionally serializable /*private final*/ NavigableSet ns; SynchronizedNavigableSet(NavigableSet s) { super(s); ns = s; } SynchronizedNavigableSet(NavigableSet s, Object mutex) { super(s, mutex); ns = s; } public E lower(E e) { synchronized (mutex) {return ns.lower(e);} } public E floor(E e) { synchronized (mutex) {return ns.floor(e);} } public E ceiling(E e) { synchronized (mutex) {return ns.ceiling(e);} } public E higher(E e) { synchronized (mutex) {return ns.higher(e);} } public E pollFirst() { synchronized (mutex) {return ns.pollFirst();} } public E pollLast() { synchronized (mutex) {return ns.pollLast();} } public NavigableSet descendingSet() { synchronized (mutex) { return new SynchronizedNavigableSet<>(ns.descendingSet(), mutex); } } public Iterator descendingIterator() { synchronized (mutex) { return descendingSet().iterator(); } } public NavigableSet subSet(E fromElement, E toElement) { synchronized (mutex) { return new SynchronizedNavigableSet<>(ns.subSet(fromElement, true, toElement, false), mutex); } } public NavigableSet headSet(E toElement) { synchronized (mutex) { return new SynchronizedNavigableSet<>(ns.headSet(toElement, false), mutex); } } public NavigableSet tailSet(E fromElement) { synchronized (mutex) { return new SynchronizedNavigableSet<>(ns.tailSet(fromElement, true), mutex); } } public NavigableSet subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) { synchronized (mutex) { return new SynchronizedNavigableSet<>(ns.subSet(fromElement, fromInclusive, toElement, toInclusive), mutex); } } public NavigableSet headSet(E toElement, boolean inclusive) { synchronized (mutex) { return new SynchronizedNavigableSet<>(ns.headSet(toElement, inclusive), mutex); } } public NavigableSet tailSet(E fromElement, boolean inclusive) { synchronized (mutex) { return new SynchronizedNavigableSet<>(ns.tailSet(fromElement, inclusive), mutex); } } }