java.util.ArrayDeque.toArray()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(155)

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

ArrayDeque.toArray介绍

[英]Returns an array containing all of the elements in this deque in proper sequence (from first to last element).

The returned array will be "safe" in that no references to it are maintained by this deque. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.
[中]返回一个数组,该数组按正确顺序(从第一个元素到最后一个元素)包含此数据集中的所有元素。
返回的数组将是“安全的”,因为此deque不维护对它的引用。(换句话说,此方法必须分配一个新数组)。因此,调用者可以自由修改返回的数组。
此方法充当基于阵列和基于集合的API之间的桥梁。

代码示例

代码示例来源:origin: spotify/apollo

public synchronized T[] copy(T[] into) {
 return deque.toArray(into);
}

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

@Override
public Collection<StreamElementQueueEntry<?>> values() throws InterruptedException {
  lock.lockInterruptibly();
  try {
    StreamElementQueueEntry<?>[] array = new StreamElementQueueEntry[queue.size()];
    array = queue.toArray(array);
    return Arrays.asList(array);
  } finally {
    lock.unlock();
  }
}

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

@Override
public Collection<StreamElementQueueEntry<?>> values() throws InterruptedException {
  lock.lockInterruptibly();
  try {
    StreamElementQueueEntry<?>[] array = new StreamElementQueueEntry[numberEntries];
    array = completedQueue.toArray(array);
    int counter = completedQueue.size();
    for (StreamElementQueueEntry<?> entry: firstSet) {
      array[counter] = entry;
      counter++;
    }
    for (Set<StreamElementQueueEntry<?>> asyncBufferEntries : uncompletedQueue) {
      for (StreamElementQueueEntry<?> streamElementQueueEntry : asyncBufferEntries) {
        array[counter] = streamElementQueueEntry;
        counter++;
      }
    }
    return Arrays.asList(array);
  } finally {
    lock.unlock();
  }
}

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

/**
 * Node left callback.
 *
 * @return {@code False} if descriptor is reserved.
 */
public boolean onNodeLeft() {
  SessionWriteRequest[] reqs = null;
  synchronized (this) {
    nodeLeft = true;
    if (reserved)
      return false;
    if (!msgReqs.isEmpty()) {
      reqs = msgReqs.toArray(new SessionWriteRequest[msgReqs.size()]);
      msgReqs.clear();
    }
  }
  if (reqs != null)
    notifyOnNodeLeft(reqs);
  return true;
}

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

/**
 *
 */
public void release() {
  SessionWriteRequest[] futs = null;
  synchronized (this) {
    ses = null;
    connected = false;
    if (handshakeReq != null) {
      IgniteInClosure<Boolean> c = handshakeReq.get2();
      assert c != null;
      handshakeReq = null;
      c.apply(true);
    }
    else {
      reserved = false;
      notifyAll();
    }
    if (nodeLeft && !msgReqs.isEmpty()) {
      futs = msgReqs.toArray(new SessionWriteRequest[msgReqs.size()]);
      msgReqs.clear();
    }
  }
  if (futs != null)
    notifyOnNodeLeft(futs);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public Object[] toArray() {
  return queue.toArray();
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public <T1> T1[] toArray(T1[] a) {
  return queue.toArray(a);
}

代码示例来源:origin: lyft/scoop

public List<Screen> asList() {
    Screen[] array = backStack.toArray(new Screen[backStack.size()]);

    List<Screen> list = Arrays.asList(array);
    Collections.reverse(list);

    return list;
  }
}

代码示例来源:origin: lyft/scoop

public List<Screen> asList() {
    Screen[] array = backStack.toArray(new Screen[backStack.size()]);

    List<Screen> list = Arrays.asList(array);
    Collections.reverse(list);

    return list;
  }
}

代码示例来源:origin: org.zeromq/jeromq

@Override
public <T> T[] toArray(T[] arg0)
{
  return frames.toArray(arg0);
}

代码示例来源:origin: freenet/fred

public Runnable[][] getQueuedJobsByPriority() {
  final Runnable[][] ret = new Runnable[jobs.length][];
  
  synchronized(jobs) {
    for(int i=0; i < jobs.length; ++i) {
      ret[i] = jobs[i].toArray(new Runnable[jobs[i].size()]);
    }
  }
  
  return ret;
}

代码示例来源:origin: espertechinc/esper

/**
 * NOTE: Code-generation-invoked method, method name and parameter order matters
 *
 * @param arrays values
 * @return array
 */
public static EventBean[][] toArrayEventsArray(ArrayDeque<EventBean[]> arrays) {
  if (arrays.isEmpty()) {
    return EVENTBEANARRAYARRAY_EMPTY;
  }
  return arrays.toArray(new EventBean[arrays.size()][]);
}

代码示例来源:origin: org.apache.flink/flink-streaming-java_2.11

@Override
public Collection<StreamElementQueueEntry<?>> values() throws InterruptedException {
  lock.lockInterruptibly();
  try {
    StreamElementQueueEntry<?>[] array = new StreamElementQueueEntry[queue.size()];
    array = queue.toArray(array);
    return Arrays.asList(array);
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: io.snappydata/gemfire-core

Object[] getAndClearSnapshotRegionEntries() {
 if (unCommittedEntryReference != null) {
  RegionEntry[] uncommittedEntries = unCommittedEntryReference.toArray(
    new RegionEntry[unCommittedEntryReference.size()]);
  Object[] committedEntries = committedEntryReference.toArray(
    new Object[committedEntryReference.size()]);
  cleanupSnapshotRegionEntries();
  return new Object[] { uncommittedEntries, committedEntries };
 } else {
  return null;
 }
}

代码示例来源:origin: org.apache.flink/flink-streaming-java_2.10

@Override
public Collection<StreamElementQueueEntry<?>> values() throws InterruptedException {
  lock.lockInterruptibly();
  try {
    StreamElementQueueEntry<?>[] array = new StreamElementQueueEntry[queue.size()];
    array = queue.toArray(array);
    return Arrays.asList(array);
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: beworker/magnet

private IllegalStateException createCircularDependencyException() {
    Instantiation[] objects = instantiations.toArray(new Instantiation[0]);
    StringBuilder builder = new StringBuilder()
      .append("Magnet failed because of unresolved circular dependency: ");
    for (int i = objects.length; i-- > 0; ) {
      builder.append(objects[i].key).append(" -> ");
    }
    builder.append(currentInstantiation.key);
    return new IllegalStateException(builder.toString());
  }
}

代码示例来源:origin: espertechinc/esper

public EventBean[] getProperty(EventBean theEvent, ExprEvaluatorContext exprEvaluatorContext) {
  ArrayDeque<EventBean> resultEvents = new ArrayDeque<EventBean>();
  eventsPerStream[0] = theEvent;
  populateEvents(theEvent, 0, resultEvents, exprEvaluatorContext);
  if (resultEvents.isEmpty()) {
    return null;
  }
  return resultEvents.toArray(new EventBean[resultEvents.size()]);
}

代码示例来源:origin: org.apache.flink/flink-streaming-java_2.10

protected void traverseAllPanes(KeyMap.TraversalEvaluator<Key, Aggregate> traversal, long traversalPass) throws Exception{
  // gather all panes in an array (faster iterations)
  @SuppressWarnings({"unchecked", "rawtypes"})
  KeyMap<Key, Aggregate>[] panes = previousPanes.toArray(new KeyMap[previousPanes.size() + 1]);
  panes[panes.length - 1] = latestPane;
  // let the maps make a coordinated traversal and evaluate the window function per contained key
  KeyMap.traverseMaps(panes, traversal, traversalPass);
}

代码示例来源:origin: espertechinc/esper

public void add(ArrayDeque<FilterItem> stack, FilterHandle filterHandle) {
    FilterItem[] filterArray = stack.toArray(new FilterItem[stack.size()]);
    List<FilterItem[]> existing = filters.get(filterHandle.getStatementId());
    if (existing == null) {
      existing = new ArrayList<>();
      filters.put(filterHandle.getStatementId(), existing);
    }
    existing.add(filterArray);
  }
};

代码示例来源:origin: espertechinc/esper

public EventBean[] getProperty(EventBean theEvent, ExprEvaluatorContext exprEvaluatorContext) {
  ArrayDeque<EventBean[]> rows = accumulative.getAccumulative(theEvent, exprEvaluatorContext);
  if ((rows == null) || (rows.isEmpty())) {
    return null;
  }
  ArrayDeque<EventBean> result = new ArrayDeque<EventBean>();
  for (EventBean[] row : rows) {
    EventBean bean = selectExprProcessor.process(row, true, false, exprEvaluatorContext);
    result.add(bean);
  }
  return result.toArray(new EventBean[result.size()]);
}

相关文章