类 ConcurrentLongPairSet

java.lang.Object
org.apache.pulsar.common.util.collections.ConcurrentLongPairSet
所有已实现的接口:
LongPairSet

public class ConcurrentLongPairSet extends Object implements LongPairSet
Concurrent hash set where values are composed of pairs of longs.

Provides similar methods as a ConcurrentHashSet<V> but since it's an open hash set with linear probing, no node allocations are required to store the keys and values, and no boxing is required.

Values MUST be >= 0.
WARN: method forEach do not guarantee thread safety, nor does the items method.
The forEach method is specifically designed for single-threaded usage. When iterating over a set with concurrent writes, it becomes possible for new values to be either observed or not observed. There is no guarantee that if we write value1 and value2, and are able to see value2, then we will also see value1.
It is crucial to understand that the results obtained from aggregate status methods such as items are typically reliable only when the map is not undergoing concurrent updates from other threads. When concurrent updates are involved, the results of these methods reflect transient states that may be suitable for monitoring or estimation purposes, but not for program control.

  • 构造器详细资料

    • ConcurrentLongPairSet

      @Deprecated public ConcurrentLongPairSet()
      已过时。
    • ConcurrentLongPairSet

      @Deprecated public ConcurrentLongPairSet(int expectedItems)
      已过时。
    • ConcurrentLongPairSet

      @Deprecated public ConcurrentLongPairSet(int expectedItems, int concurrencyLevel)
      已过时。
    • ConcurrentLongPairSet

      public ConcurrentLongPairSet(int expectedItems, int concurrencyLevel, float mapFillFactor, float mapIdleFactor, boolean autoShrink, float expandFactor, float shrinkFactor)
  • 方法详细资料

    • newBuilder

      public static ConcurrentLongPairSet.Builder newBuilder()
    • size

      public long size()
      从接口复制的说明: LongPairSet
      Returns size of the set.
      指定者:
      size 在接口中 LongPairSet
      返回:
    • capacity

      public long capacity()
      从接口复制的说明: LongPairSet
      Returns capacity of the set.
      指定者:
      capacity 在接口中 LongPairSet
      返回:
    • isEmpty

      public boolean isEmpty()
      从接口复制的说明: LongPairSet
      Check if set is empty.
      指定者:
      isEmpty 在接口中 LongPairSet
      返回:
    • contains

      public boolean contains(long item1, long item2)
      从接口复制的说明: LongPairSet
      Checks if given (item1,item2) composite value exists into set.
      指定者:
      contains 在接口中 LongPairSet
      返回:
    • add

      public boolean add(long item1, long item2)
      从接口复制的说明: LongPairSet
      Adds composite value of item1 and item2 to set.
      指定者:
      add 在接口中 LongPairSet
      返回:
    • remove

      public boolean remove(long item1, long item2)
      Remove an existing entry if found.
      指定者:
      remove 在接口中 LongPairSet
      参数:
      item1 -
      返回:
      true if removed or false if item was not present
    • clear

      public void clear()
      从接口复制的说明: LongPairSet
      Removes all items from set.
      指定者:
      clear 在接口中 LongPairSet
    • forEach

      public void forEach(ConcurrentLongPairSet.LongPairConsumer processor)
      Iterate over all the elements in the set and apply the provided function.

      Warning: Do Not Guarantee Thread-Safety.

      指定者:
      forEach 在接口中 LongPairSet
      参数:
      processor - the processor to process the elements
    • removeIf

      public int removeIf(LongPairSet.LongPairPredicate filter)
      Removes all of the elements of this collection that satisfy the given predicate.
      指定者:
      removeIf 在接口中 LongPairSet
      参数:
      filter - a predicate which returns true for elements to be removed
      返回:
      number of removed values
    • items

      指定者:
      items 在接口中 LongPairSet
      返回:
      a new set of all keys (makes a copy)
    • items

      public Set<ConcurrentLongPairSet.LongPair> items(int numberOfItems)
      指定者:
      items 在接口中 LongPairSet
      返回:
      a new list of keys with max provided numberOfItems (makes a copy)
    • items

      public <T> Set<T> items(int numberOfItems, LongPairSet.LongPairFunction<T> longPairConverter)
      指定者:
      items 在接口中 LongPairSet
      longPairConverter - converts (long,long) pair to object
      返回:
      a new list of keys with max provided numberOfItems
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object