Package org.apache.ignite.internal.util
Class GridBoundedConcurrentOrderedSet<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- org.apache.ignite.internal.util.GridSerializableSet<E>
-
- org.apache.ignite.internal.util.GridConcurrentSkipListSet<E>
-
- org.apache.ignite.internal.util.GridBoundedConcurrentOrderedSet<E>
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<E>,Collection<E>,NavigableSet<E>,Set<E>,SortedSet<E>
public class GridBoundedConcurrentOrderedSet<E> extends GridConcurrentSkipListSet<E>
Concurrent ordered set that automatically manages its maximum size. Once it exceeds its maximum, it will start removing smallest elements until the maximum is reached again.Note that due to concurrent nature of this set, it may grow slightly larger than its maximum allowed size, but in this case it will quickly readjust back to allowed size.
Note that
remove(Object)method is not supported for this kind of set.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GridBoundedConcurrentOrderedSet(int max)Constructs a new, empty set that orders its elements according to their natural ordering.GridBoundedConcurrentOrderedSet(int max, Collection<? extends E> c)Constructs a new set containing the elements in the specified collection, that orders its elements according to their natural ordering.GridBoundedConcurrentOrderedSet(int max, Comparator<? super E> comp)Constructs a new, empty set that orders its elements according to the specified comparator.GridBoundedConcurrentOrderedSet(int max, SortedSet<E> s)Constructs a new set containing the same elements and using the same ordering as the specified sorted set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E e)GridBoundedConcurrentOrderedSet<E>clone()booleanremove(Object o)This method is not supported and always throwsUnsupportedOperationException.intsize()Approximate size at this point of time.-
Methods inherited from class org.apache.ignite.internal.util.GridConcurrentSkipListSet
ceiling, clear, comparator, contains, descendingIterator, descendingSet, equals, first, firstx, floor, hashCode, headSet, headSet, higher, isEmpty, iterator, last, lastx, lower, pollFirst, pollLast, removeAll, subSet, subSet, tailSet, tailSet
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.SortedSet
spliterator
-
-
-
-
Constructor Detail
-
GridBoundedConcurrentOrderedSet
public GridBoundedConcurrentOrderedSet(int max)
Constructs a new, empty set that orders its elements according to their natural ordering.- Parameters:
max- Upper bound of this set.
-
GridBoundedConcurrentOrderedSet
public GridBoundedConcurrentOrderedSet(int max, Comparator<? super E> comp)Constructs a new, empty set that orders its elements according to the specified comparator.- Parameters:
max- Upper bound of this set.comp- the comparator that will be used to order this set. If null, the natural ordering of the elements will be used.
-
GridBoundedConcurrentOrderedSet
public GridBoundedConcurrentOrderedSet(int max, Collection<? extends E> c)Constructs a new set containing the elements in the specified collection, that orders its elements according to their natural ordering.- Parameters:
max- Upper bound of this set.c- The elements that will comprise the new set- Throws:
ClassCastException- if the elements in c are notComparable, or are not mutually comparableNullPointerException- if the specified collection or any of its elements arenull.
-
GridBoundedConcurrentOrderedSet
public GridBoundedConcurrentOrderedSet(int max, SortedSet<E> s)Constructs a new set containing the same elements and using the same ordering as the specified sorted set.- Parameters:
max- Upper bound of this set.s- sorted set whose elements will comprise the new set- Throws:
NullPointerException- if the specified sorted set or any of its elements arenull.
-
-
Method Detail
-
add
public boolean add(E e)
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classGridConcurrentSkipListSet<E>
-
size
public int size()
Approximate size at this point of time. Note, that unlikesizemethods on otherconcurrentcollections, this method executes in constant time without traversal of the elements.- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Overrides:
sizein classGridConcurrentSkipListSet<E>- Returns:
- Approximate set size at this point of time.
-
clone
public GridBoundedConcurrentOrderedSet<E> clone()
- Overrides:
clonein classGridConcurrentSkipListSet<E>
-
remove
public boolean remove(Object o)
This method is not supported and always throwsUnsupportedOperationException.- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classGridConcurrentSkipListSet<E>- Parameters:
o-- Returns:
-
-