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

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

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

WeakHashSet.toArray介绍

[英]Returns a view of this set as an array. Elements will be in an arbitrary order. Note that this array contains strong references. Consequently, no object reclamation will occur as long as a reference to this array is hold.
[中]将此集合的视图作为数组返回。元素将按任意顺序排列。请注意,此数组包含强引用。因此,只要保留对该数组的引用,就不会发生对象回收。

代码示例

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

/**
   * Returns an iterator over the elements contained in this collection.
   * No element from this set will be garbage collected as long as a
   * reference to the iterator is hold.
   *
   * @return an iterator over all elements in this set.
   */
  @Override
  public Iterator<E> iterator() {
    return Arrays.asList(toArray()).iterator();
  }
}

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

/**
   * Returns an iterator over the elements contained in this collection.
   * No element from this set will be garbage collected as long as a
   * reference to the iterator is hold.
   *
   * @return an iterator over all elements in this set.
   */
  @Override
  public Iterator<E> iterator() {
    return Arrays.asList(toArray()).iterator();
  }
}

代码示例来源: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;
}

相关文章

微信公众号

最新文章

更多