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 and 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
`boolean` `add(E e)`
`GridBoundedConcurrentOrderedSet<E>` `clone()`
`boolean` `remove(Object o)` This method is not supported and always throws `UnsupportedOperationException`.
`int` `size()` 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.SortedSet

`spliterator`

### Methods inherited from interface java.util.Set

`addAll, containsAll, retainAll, toArray, toArray`

### Methods inherited from interface java.util.Collection

`parallelStream, removeIf, stream`

### Methods inherited from interface java.lang.Iterable

`forEach`

### 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 not `Comparable`, or are not mutually comparable
  `NullPointerException` - if the specified collection or any of its elements are `null`.

#### 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 are `null`.

### Method Detail

#### add

    public boolean add(E e)

Specified by:
  `add` in interface `Collection<E>`
Specified by:
  `add` in interface `Set<E>`
Overrides:
  `add` in class `GridConcurrentSkipListSet<E>`

#### size

    public int size()

Approximate size at this point of time. Note, that unlike `size` methods on other `concurrent` collections, this method executes in constant time without traversal of the elements.

Specified by:
  `size` in interface `Collection<E>`
Specified by:
  `size` in interface `Set<E>`
Overrides:
  `size` in class `GridConcurrentSkipListSet<E>`
Returns:
  Approximate set size at this point of time.

#### clone

    public GridBoundedConcurrentOrderedSet<E> clone()

Overrides:
  `clone` in class `GridConcurrentSkipListSet<E>`

#### remove

    public boolean remove(Object o)

This method is not supported and always throws `UnsupportedOperationException`.

Specified by:
  `remove` in interface `Collection<E>`
Specified by:
  `remove` in interface `Set<E>`
Overrides:
  `remove` in class `GridConcurrentSkipListSet<E>`
Parameters:
  `o` -
Returns:

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022