/** * Returns a synchronized sorted set backed by the given sorted set. * <p> * You must manually synchronize on the returned buffer's iterator to * avoid non-deterministic behavior: * * <pre> * Set s = SetUtils.synchronizedSet(mySet); * synchronized (s) { * Iterator i = s.iterator(); * while (i.hasNext()) { * process (i.next()); * } * } * </pre> * * This method uses the implementation in the decorators subpackage. * * @param set the sorted set to synchronize, must not be null * @return a synchronized set backed by the given set * @throws IllegalArgumentException if the set is null */ public static SortedSet synchronizedSortedSet(SortedSet set) { return SynchronizedSortedSet.decorate(set); }
public SortedSet tailSet(Object fromElement) { synchronized (lock) { SortedSet set = getSortedSet().tailSet(fromElement); // the lock is passed into the constructor here to ensure that the // tailset is synchronized on the same lock as the parent return new SynchronizedSortedSet(set, lock); } }
public Object first() { synchronized (lock) { return getSortedSet().first(); } }
/** * Factory method to create a synchronized set. * * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ public static SortedSet decorate(SortedSet set) { return new SynchronizedSortedSet(set); }
public Object last() { synchronized (lock) { return getSortedSet().last(); } }
/** * Factory method to create a synchronized set. * * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ public static SortedSet decorate(SortedSet set) { return new SynchronizedSortedSet(set); }
public SortedSet headSet(Object toElement) { synchronized (lock) { SortedSet set = getSortedSet().headSet(toElement); // the lock is passed into the constructor here to ensure that the // headset is synchronized on the same lock as the parent return new SynchronizedSortedSet(set, lock); } }
public Comparator comparator() { synchronized (lock) { return getSortedSet().comparator(); } }
/** * Returns a synchronized sorted set backed by the given sorted set. * <p> * You must manually synchronize on the returned buffer's iterator to * avoid non-deterministic behavior: * * <pre> * Set s = SetUtils.synchronizedSet(mySet); * synchronized (s) { * Iterator i = s.iterator(); * while (i.hasNext()) { * process (i.next()); * } * } * </pre> * * This method uses the implementation in the decorators subpackage. * * @param set the sorted set to synchronize, must not be null * @return a synchronized set backed by the given set * @throws IllegalArgumentException if the set is null */ public static SortedSet synchronizedSortedSet(SortedSet set) { return SynchronizedSortedSet.decorate(set); }
/** * Factory method to create a synchronized set. * * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ public static SortedSet decorate(SortedSet set) { return new SynchronizedSortedSet(set); }
public SortedSet headSet(Object toElement) { synchronized (lock) { SortedSet set = getSortedSet().headSet(toElement); // the lock is passed into the constructor here to ensure that the // headset is synchronized on the same lock as the parent return new SynchronizedSortedSet(set, lock); } }
public Object first() { synchronized (lock) { return getSortedSet().first(); } }
public Set makeEmptySet() { return SynchronizedSortedSet.decorate(new TreeSet()); }
/** * Factory method to create a synchronized set. * * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ public static SortedSet decorate(SortedSet set) { return new SynchronizedSortedSet(set); }
public SortedSet tailSet(Object fromElement) { synchronized (lock) { SortedSet set = getSortedSet().tailSet(fromElement); // the lock is passed into the constructor here to ensure that the // tailset is synchronized on the same lock as the parent return new SynchronizedSortedSet(set, lock); } }
public Object last() { synchronized (lock) { return getSortedSet().last(); } }
/** * Returns a synchronized sorted set backed by the given sorted set. * <p> * You must manually synchronize on the returned buffer's iterator to * avoid non-deterministic behavior: * * <pre> * Set s = SetUtils.synchronizedSet(mySet); * synchronized (s) { * Iterator i = s.iterator(); * while (i.hasNext()) { * process (i.next()); * } * } * </pre> * * This method uses the implementation in the decorators subpackage. * * @param set the sorted set to synchronize, must not be null * @return a synchronized set backed by the given set * @throws IllegalArgumentException if the set is null */ public static SortedSet synchronizedSortedSet(SortedSet set) { return SynchronizedSortedSet.decorate(set); }
/** * Factory method to create a synchronized set. * * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ public static SortedSet decorate(SortedSet set) { return new SynchronizedSortedSet(set); }
public SortedSet subSet(Object fromElement, Object toElement) { synchronized (lock) { SortedSet set = getSortedSet().subSet(fromElement, toElement); // the lock is passed into the constructor here to ensure that the // subset is synchronized on the same lock as the parent return new SynchronizedSortedSet(set, lock); } }
public Comparator comparator() { synchronized (lock) { return getSortedSet().comparator(); } }