org.apache.sis.util.collection.WeakHashSet.size()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.apache.sis.util.collection.WeakHashSet.size()方法的一些代码示例,展示了WeakHashSet.size()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeakHashSet.size()方法的具体详情如下:
包路径:org.apache.sis.util.collection.WeakHashSet
类名称:WeakHashSet
方法名:size

WeakHashSet.size介绍

[英]Returns the count of element in this set.
[中]返回此集合中元素的计数。

代码示例

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Returns an array containing every instances of this type that have not yet been
 * garbage collected. The first elements of the returned array are the constants
 * defined in this class, in declaration order. All other elements are the instances
 * created by the {@link #valueOf(String)} method, in no particular order.
 *
 * @return an array containing the instances of {@code NilReason}.
 */
public static NilReason[] values() {
  final int predefinedCount = PREDEFINED.length;
  NilReason[] reasons;
  synchronized (POOL) {
    reasons = POOL.toArray(new NilReason[predefinedCount + POOL.size()]);
  }
  int count = reasons.length;
  while (count != 0 && reasons[count-1] == null) {
    count--;
  }
  count += predefinedCount;
  final NilReason[] source = reasons;
  if (count != reasons.length) {
    reasons = new NilReason[count];
  }
  System.arraycopy(source, 0, reasons, predefinedCount, count - predefinedCount);
  System.arraycopy(PREDEFINED, 0, reasons, 0, predefinedCount);
  return reasons;
}

代码示例来源:origin: apache/sis

/**
 * Returns an array containing every instances of this type that have not yet been
 * garbage collected. The first elements of the returned array are the constants
 * defined in this class, in declaration order. All other elements are the instances
 * created by the {@link #valueOf(String)} method, in no particular order.
 *
 * @return an array containing the instances of {@code NilReason}.
 */
public static NilReason[] values() {
  final int predefinedCount = PREDEFINED.length;
  NilReason[] reasons;
  synchronized (POOL) {
    reasons = POOL.toArray(new NilReason[predefinedCount + POOL.size()]);
  }
  int count = reasons.length;
  while (count != 0 && reasons[count-1] == null) {
    count--;
  }
  count += predefinedCount;
  final NilReason[] source = reasons;
  if (count != reasons.length) {
    reasons = new NilReason[count];
  }
  System.arraycopy(source, 0, reasons, predefinedCount, count - predefinedCount);
  System.arraycopy(PREDEFINED, 0, reasons, 0, predefinedCount);
  return reasons;
}

代码示例来源:origin: apache/sis

waitForGarbageCollection(() -> weakSet.size() == strongSet.size());
assertSetEquals(strongSet, weakSet);

相关文章

微信公众号

最新文章

更多