Methods Summary |
---|
public boolean | add(E e)Adds the specified element to this set if it is not already present.
More formally, adds the specified element e to this set if
the set contains no element e2 such that e.equals(e2).
If this set already contains the element, the call leaves the set
unchanged and returns false.
return m.putIfAbsent(e, Boolean.TRUE) == null;
|
public E | ceiling(E e)
return m.ceilingKey(e);
|
public void | clear()Removes all of the elements from this set.
m.clear();
|
public java.util.concurrent.ConcurrentSkipListSet | clone()Returns a shallow copy of this ConcurrentSkipListSet
instance. (The elements themselves are not cloned.)
ConcurrentSkipListSet<E> clone = null;
try {
clone = (ConcurrentSkipListSet<E>) super.clone();
clone.setMap(new ConcurrentSkipListMap(m));
} catch (CloneNotSupportedException e) {
throw new InternalError();
}
return clone;
|
public java.util.Comparator | comparator()
return m.comparator();
|
public boolean | contains(java.lang.Object o)Returns true if this set contains the specified element.
More formally, returns true if and only if this set
contains an element e such that o.equals(e).
return m.containsKey(o);
|
public java.util.Iterator | descendingIterator()Returns an iterator over the elements in this set in descending order.
return m.descendingKeySet().iterator();
|
public java.util.NavigableSet | descendingSet()Returns a reverse order view of the elements contained in this set.
The descending set is backed by this set, so changes to the set are
reflected in the descending set, and vice-versa.
The returned set has an ordering equivalent to
{@link Collections#reverseOrder(Comparator) Collections.reverseOrder}(comparator()).
The expression {@code s.descendingSet().descendingSet()} returns a
view of {@code s} essentially equivalent to {@code s}.
return new ConcurrentSkipListSet(m.descendingMap());
|
public boolean | equals(java.lang.Object o)Compares the specified object with this set for equality. Returns
true 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.
// 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 E | first()
return m.firstKey();
|
public E | floor(E e)
return m.floorKey(e);
|
public java.util.NavigableSet | headSet(E toElement, boolean inclusive)
return new ConcurrentSkipListSet<E>(m.headMap(toElement, inclusive));
|
public java.util.NavigableSet | headSet(E toElement)
return headSet(toElement, false);
|
public E | higher(E e)
return m.higherKey(e);
|
public boolean | isEmpty()Returns true if this set contains no elements.
return m.isEmpty();
|
public java.util.Iterator | iterator()Returns an iterator over the elements in this set in ascending order.
return m.navigableKeySet().iterator();
|
public E | last()
return m.lastKey();
|
public E | lower(E e)
return m.lowerKey(e);
|
public E | pollFirst()
Map.Entry<E,Object> e = m.pollFirstEntry();
return e == null? null : e.getKey();
|
public E | pollLast()
Map.Entry<E,Object> e = m.pollLastEntry();
return e == null? null : e.getKey();
|
public boolean | remove(java.lang.Object o)Removes the specified element from this set if it is present.
More formally, removes an element e such that
o.equals(e), if this set contains such an element.
Returns true if this set contained the element (or
equivalently, if this set changed as a result of the call).
(This set will not contain the element once the call returns.)
return m.remove(o, Boolean.TRUE);
|
public boolean | removeAll(java.util.Collection c)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 asymmetric set difference of the two sets.
// 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;
|
private void | setMap(java.util.concurrent.ConcurrentNavigableMap map)
try {
mapOffset = unsafe.objectFieldOffset
(ConcurrentSkipListSet.class.getDeclaredField("m"));
} catch (Exception ex) { throw new Error(ex); }
unsafe.putObjectVolatile(this, mapOffset, map);
|
public int | size()Returns the number of elements in this set. If this set
contains more than Integer.MAX_VALUE elements, it
returns Integer.MAX_VALUE.
Beware that, unlike in most collections, this method is
NOT a constant-time operation. Because of the
asynchronous nature of these sets, determining the current
number of elements requires traversing them all to count them.
Additionally, it is possible for the size to change during
execution of this method, in which case the returned result
will be inaccurate. Thus, this method is typically not very
useful in concurrent applications.
return m.size();
|
public java.util.NavigableSet | subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
return new ConcurrentSkipListSet<E>
(m.subMap(fromElement, fromInclusive,
toElement, toInclusive));
|
public java.util.NavigableSet | subSet(E fromElement, E toElement)
return subSet(fromElement, true, toElement, false);
|
public java.util.NavigableSet | tailSet(E fromElement, boolean inclusive)
return new ConcurrentSkipListSet<E>(m.tailMap(fromElement, inclusive));
|
public java.util.NavigableSet | tailSet(E fromElement)
return tailSet(fromElement, true);
|