/** * @throws ClassCastException {@inheritDoc} * @throws NullPointerException if {@code toElement} is null * @throws IllegalArgumentException {@inheritDoc} */ public SortedSet headSet(Object toElement) { return headSet(toElement, false); }
/** * @throws ClassCastException {@inheritDoc} * @throws NullPointerException if {@code fromElement} or * {@code toElement} is null * @throws IllegalArgumentException {@inheritDoc} */ public SortedSet subSet(Object fromElement, Object toElement) { return subSet(fromElement, true, toElement, false); }
/** * @throws ClassCastException {@inheritDoc} * @throws NullPointerException if {@code fromElement} is null * @throws IllegalArgumentException {@inheritDoc} */ public SortedSet tailSet(Object fromElement) { return tailSet(fromElement, true); }
/** * @throws ClassCastException {@inheritDoc} * @throws NullPointerException if {@code toElement} is null * @throws IllegalArgumentException {@inheritDoc} */ public NavigableSet headSet(Object toElement, boolean inclusive) { return new ConcurrentSkipListSet( (ConcurrentNavigableMap)m.headMap(toElement, inclusive)); }
/** * Constructs a new set containing the same elements and using the * same ordering as the specified sorted set. * * @param s sorted set whose elements will comprise the new set * @throws NullPointerException if the specified sorted set or any * of its elements are null */ public ConcurrentSkipListSet(SortedSet s) { m = new ConcurrentSkipListMap(s.comparator()); addAll(s); }
/** * Removes from this set all of its elements that are contained in * the specified collection. If the specified collection is also * a set, this operation effectively modifies this set so that its * value is the <i>asymmetric set difference</i> of the two sets. * * @param c collection containing elements to be removed from this set * @return <tt>true</tt> if this set changed as a result of the call * @throws ClassCastException if the types of one or more elements in this * set are incompatible with the specified collection * @throws NullPointerException if the specified collection or any * of its elements are null */ public boolean removeAll(Collection c) { // Override AbstractSet version to avoid unnecessary call to size() boolean modified = false; for (Iterator i = c.iterator(); i.hasNext(); ) if (remove(i.next())) modified = true; return modified; }
/** * Compares the specified object with this set for equality. Returns * <tt>true</tt> if the specified object is also a set, the two sets * have the same size, and every member of the specified set is * contained in this set (or equivalently, every member of this set is * contained in the specified set). This definition ensures that the * equals method works properly across different implementations of the * set interface. * * @param o the object to be compared for equality with this set * @return <tt>true</tt> if the specified object is equal to this set */ public boolean equals(Object o) { // Override AbstractSet version to avoid calling size() if (o == this) return true; if (!(o instanceof Set)) return false; Collection c = (Collection) o; try { return containsAll(c) && c.containsAll(this); } catch (ClassCastException unused) { return false; } catch (NullPointerException unused) { return false; } }
public NavigableSet headSet(Object toElement, boolean inclusive) { return new ConcurrentSkipListSet( (ConcurrentNavigableMap)m.headMap(toElement, inclusive)); } public NavigableSet tailSet(Object fromElement, boolean inclusive) {
/** * Constructs a new set containing the same elements and using the * same ordering as the specified sorted set. * * @param s sorted set whose elements will comprise the new set * @throws NullPointerException if the specified sorted set or any * of its elements are null */ public ConcurrentSkipListSet(SortedSet s) { m = new ConcurrentSkipListMap(s.comparator()); addAll(s); }
/** * Removes from this set all of its elements that are contained in * the specified collection. If the specified collection is also * a set, this operation effectively modifies this set so that its * value is the <i>asymmetric set difference</i> of the two sets. * * @param c collection containing elements to be removed from this set * @return <tt>true</tt> if this set changed as a result of the call * @throws ClassCastException if the types of one or more elements in this * set are incompatible with the specified collection * @throws NullPointerException if the specified collection or any * of its elements are null */ public boolean removeAll(Collection c) { // Override AbstractSet version to avoid unnecessary call to size() boolean modified = false; for (Iterator i = c.iterator(); i.hasNext(); ) if (remove(i.next())) modified = true; return modified; }
/** * Compares the specified object with this set for equality. Returns * <tt>true</tt> if the specified object is also a set, the two sets * have the same size, and every member of the specified set is * contained in this set (or equivalently, every member of this set is * contained in the specified set). This definition ensures that the * equals method works properly across different implementations of the * set interface. * * @param o the object to be compared for equality with this set * @return <tt>true</tt> if the specified object is equal to this set */ public boolean equals(Object o) { // Override AbstractSet version to avoid calling size() if (o == this) return true; if (!(o instanceof Set)) return false; Collection c = (Collection) o; try { return containsAll(c) && c.containsAll(this); } catch (ClassCastException unused) { return false; } catch (NullPointerException unused) { return false; } }
public NavigableSet tailSet(Object fromElement, boolean inclusive) { return new ConcurrentSkipListSet( (ConcurrentNavigableMap)m.tailMap(fromElement, inclusive)); } public SortedSet subSet(Object fromElement, Object toElement) {
/** * Constructs a new set containing the same elements and using the * same ordering as the specified sorted set. * * @param s sorted set whose elements will comprise the new set * @throws NullPointerException if the specified sorted set or any * of its elements are null */ public ConcurrentSkipListSet(SortedSet s) { m = new ConcurrentSkipListMap(s.comparator()); addAll(s); }
/** * @throws ClassCastException {@inheritDoc} * @throws NullPointerException if {@code fromElement} is null * @throws IllegalArgumentException {@inheritDoc} */ public SortedSet tailSet(Object fromElement) { return tailSet(fromElement, true); }
/** * @throws ClassCastException {@inheritDoc} * @throws NullPointerException if {@code toElement} is null * @throws IllegalArgumentException {@inheritDoc} */ public SortedSet headSet(Object toElement) { return headSet(toElement, false); }
/** * @throws ClassCastException {@inheritDoc} * @throws NullPointerException if {@code fromElement} or * {@code toElement} is null * @throws IllegalArgumentException {@inheritDoc} */ public SortedSet subSet(Object fromElement, Object toElement) { return subSet(fromElement, true, toElement, false); }
/** * Removes from this set all of its elements that are contained in * the specified collection. If the specified collection is also * a set, this operation effectively modifies this set so that its * value is the <i>asymmetric set difference</i> of the two sets. * * @param c collection containing elements to be removed from this set * @return <tt>true</tt> if this set changed as a result of the call * @throws ClassCastException if the types of one or more elements in this * set are incompatible with the specified collection * @throws NullPointerException if the specified collection or any * of its elements are null */ public boolean removeAll(Collection c) { // Override AbstractSet version to avoid unnecessary call to size() boolean modified = false; for (Iterator i = c.iterator(); i.hasNext(); ) if (remove(i.next())) modified = true; return modified; }
/** * Compares the specified object with this set for equality. Returns * <tt>true</tt> if the specified object is also a set, the two sets * have the same size, and every member of the specified set is * contained in this set (or equivalently, every member of this set is * contained in the specified set). This definition ensures that the * equals method works properly across different implementations of the * set interface. * * @param o the object to be compared for equality with this set * @return <tt>true</tt> if the specified object is equal to this set */ public boolean equals(Object o) { // Override AbstractSet version to avoid calling size() if (o == this) return true; if (!(o instanceof Set)) return false; Collection c = (Collection) o; try { return containsAll(c) && c.containsAll(this); } catch (ClassCastException unused) { return false; } catch (NullPointerException unused) { return false; } }
/** * @throws ClassCastException {@inheritDoc} * @throws NullPointerException if {@code toElement} is null * @throws IllegalArgumentException {@inheritDoc} */ public NavigableSet headSet(Object toElement, boolean inclusive) { return new ConcurrentSkipListSet( (ConcurrentNavigableMap)m.headMap(toElement, inclusive)); }
/** * Constructs a new set containing the elements in the specified * collection, that orders its elements according to their * {@linkplain Comparable natural ordering}. * * @param c The elements that will comprise the new set * @throws ClassCastException if the elements in <tt>c</tt> are * not {@link Comparable}, or are not mutually comparable * @throws NullPointerException if the specified collection or any * of its elements are null */ public ConcurrentSkipListSet(Collection c) { m = new ConcurrentSkipListMap(); addAll(c); }