Class GridBoundedConcurrentLinkedHashSet<E>

  • All Implemented Interfaces:
    Serializable, Iterable<E>, Collection<E>, Set<E>

    public class GridBoundedConcurrentLinkedHashSet<E>
    extends GridSetWrapper<E>
    Concurrent set with an upper bound. Once set reaches its maximum capacity, the eldest elements will be removed based on insertion or access order.
    See Also:
    Serialized Form
    • Constructor Detail

      • GridBoundedConcurrentLinkedHashSet

        public GridBoundedConcurrentLinkedHashSet​(int max)
        Creates a new, empty set with specified order and default initial capacity (16), load factor (0.75) and concurrencyLevel (16).
        Parameters:
        max - Upper bound of this set.
      • GridBoundedConcurrentLinkedHashSet

        public GridBoundedConcurrentLinkedHashSet​(int max,
                                                  int initCap)
        Creates a new, empty set with the specified initial capacity, and with default load factor (0.75) and concurrencyLevel (16).
        Parameters:
        max - Upper bound of this set.
        initCap - the initial capacity. The implementation performs internal sizing to accommodate this many elements.
        Throws:
        IllegalArgumentException - if the initial capacity of elements is negative.
      • GridBoundedConcurrentLinkedHashSet

        public GridBoundedConcurrentLinkedHashSet​(int max,
                                                  int initCap,
                                                  float loadFactor)
        Creates a new, empty set with the specified initial capacity and load factor and with the default concurrencyLevel (16).
        Parameters:
        max - Upper bound of this set.
        initCap - The implementation performs internal sizing to accommodate this many elements.
        loadFactor - the load factor threshold, used to control resizing. Resizing may be performed when the average number of elements per bin exceeds this threshold.
        Throws:
        IllegalArgumentException - if the initial capacity of elements is negative or the load factor is nonpositive.
      • GridBoundedConcurrentLinkedHashSet

        public GridBoundedConcurrentLinkedHashSet​(int max,
                                                  int initCap,
                                                  float loadFactor,
                                                  int concurLvl)
        Creates a new, empty set with the specified initial capacity, load factor and concurrency level.
        Parameters:
        max - Upper bound of this set.
        initCap - the initial capacity. The implementation performs internal sizing to accommodate this many elements.
        loadFactor - the load factor threshold, used to control resizing. Resizing may be performed when the average number of elements per bin exceeds this threshold.
        concurLvl - the estimated number of concurrently updating threads. The implementation performs internal sizing to try to accommodate this many threads.
        Throws:
        IllegalArgumentException - if the initial capacity is negative or the load factor or concurLvl are nonpositive.
      • GridBoundedConcurrentLinkedHashSet

        public GridBoundedConcurrentLinkedHashSet​(int max,
                                                  int initCap,
                                                  float loadFactor,
                                                  int concurLvl,
                                                  ConcurrentLinkedHashMap.QueuePolicy qPlc)
        Creates a new, empty set with the specified initial capacity, load factor and concurrency level.
        Parameters:
        max - Upper bound of this set.
        initCap - the initial capacity. The implementation performs internal sizing to accommodate this many elements.
        loadFactor - the load factor threshold, used to control resizing. Resizing may be performed when the average number of elements per bin exceeds this threshold.
        concurLvl - the estimated number of concurrently updating threads. The implementation performs internal sizing to try to accommodate this many threads.
        qPlc - Queue policy.
        Throws:
        IllegalArgumentException - if the initial capacity is negative or the load factor or concurLvl are nonpositive.
    • Method Detail

      • add

        public boolean add​(E e)
        Note that unlike regular add operation on a set, this method will only add the passed in element if it's not already present in set.
        Specified by:
        add in interface Collection<E>
        Specified by:
        add in interface Set<E>
        Overrides:
        add in class GridSetWrapper<E>
        Parameters:
        e - Element to add.
        Returns:
        True if element was added.
      • addx

        @Nullable
        public E addx​(E e)
        Note that unlike regular add operation on a set, this method will only add the passed in element if it's not already present in set.
        Parameters:
        e - Element to add.
        Returns:
        Value previously present in set or null if set didn't have this value.
      • sizex

        public int sizex()
        Returns:
        Size of the set