/** * Returns an array containing all of the elements in this queue. * The returned array elements are in no particular order. * * <p>The returned array will be "safe" in that no references to it are * maintained by this queue. (In other words, this method must allocate * a new array). The caller is thus free to modify the returned array. * * <p>This method acts as bridge between array-based and collection-based * APIs. * * @return an array containing all of the elements in this queue */ public Object[] toArray() { final ReentrantLock lock = this.lock; lock.lock(); try { return q.toArray(); } finally { lock.unlock(); } }
lock.lock(); try { return q.toArray(a); } finally { lock.unlock();
@Override public Result<TopNResultValue> build() { // Pull out top aggregated values final DimValHolder[] holderValueArray = pQueue.toArray(new DimValHolder[0]); Arrays.sort( holderValueArray, (o1, o2) -> comparator.compare(o1.getDimValue(), o2.getDimValue()) ); return new Result<>( timestamp, new TopNResultValue(Lists.transform(Arrays.asList(holderValueArray), DimValHolder::getMetricValues)) ); }
@Override public void afterHeuristicChange(boolean forward, boolean backward) { if (forward) { // update PQ due to heuristic change (i.e. weight changed) if (!pqOpenSetFrom.isEmpty()) { // copy into temporary array to avoid pointer change of PQ AStarEntry[] entries = pqOpenSetFrom.toArray(new AStarEntry[pqOpenSetFrom.size()]); pqOpenSetFrom.clear(); for (AStarEntry value : entries) { value.weight = value.weightOfVisitedPath + weightApprox.approximate(value.adjNode, false); // does not work for edge based // ignoreExplorationFrom.add(value.adjNode); pqOpenSetFrom.add(value); } } } if (backward) { if (!pqOpenSetTo.isEmpty()) { AStarEntry[] entries = pqOpenSetTo.toArray(new AStarEntry[pqOpenSetTo.size()]); pqOpenSetTo.clear(); for (AStarEntry value : entries) { value.weight = value.weightOfVisitedPath + weightApprox.approximate(value.adjNode, true); // ignoreExplorationTo.add(value.adjNode); pqOpenSetTo.add(value); } } } }
@Override public Result<TopNResultValue> build() { final DimValHolder[] holderValueArray = pQueue.toArray(new DimValHolder[0]); Arrays.sort( holderValueArray, (d1, d2) -> { // Metric values flipped compared to dimValueHolderComparator. //noinspection unchecked int retVal = metricComparator.compare(d2.getTopNMetricVal(), d1.getTopNMetricVal()); if (retVal == 0) { retVal = dimValueComparator.compare(d1.getDimValue(), d2.getDimValue()); } return retVal; } ); List<DimValHolder> holderValues = Arrays.asList(holderValueArray); // Pull out top aggregated values final List<Map<String, Object>> values = Lists.transform(holderValues, DimValHolder::getMetricValues); return new Result<>(timestamp, new TopNResultValue(values)); } }
final ScoreTerm[] scoreTerms = stQueue.toArray(new ScoreTerm[stQueue.size()]); ArrayUtil.timSort(scoreTerms, scoreTermSortByTermComp);
indexes.toArray( new Index[ indexes.size() ] ), otherConditions.toArray( new int[ otherConditions.size() ][] ) };
@SuppressWarnings("hiding") @Override public <T> T[] toArray(T[] a) { return this.queue.toArray(a); }
@Override public Object[] toArray() { return this.queue.toArray(); }
@Override public Iterator<T> iterator() { @SuppressWarnings("unchecked") T[] array = (T[]) this.queue.toArray(); if (this.comparator == null) { Arrays.sort(array); } else { Arrays.sort( array, this.comparator);} return Iterators.forArray(array); }
@Override public Object[] toArray() { return this.queue.toArray(); }
@SuppressWarnings("unchecked") @Override public Object[] toArray() { Object[] array = queue.toArray(); for (int i = array.length; i-- > 0; ) { array[i] = ((StableWrapper<E>)array[i]).object; } return array; }
@Override public DriftDetectionSchedule[] toArray() { try { lock.readLock().lock(); return queue.toArray(new DriftDetectionSchedule[queue.size()]); } finally { lock.readLock().unlock(); } } }
private void initFromPriorityQueue(PriorityQueue<? extends E> c) { if (c.getClass() == PriorityQueue.class) { this.queue = c.toArray(); this.size = c.size(); } else { initFromCollection(c); } }
@Override public Object[] toArray() { if (!_directAccess && isDelayLoad()) { load(); } return super.toArray(); }
@Override public Object[] toArray() { if (!_directAccess && isDelayLoad()) { load(); } return super.toArray(); }
@Override public Object[] toArray(Object[] array) { if (!_directAccess && isDelayLoad()) { load(); } return super.toArray(array); }
@Override public Object[] toArray(Object[] array) { if (!_directAccess && isDelayLoad()) { load(); } return super.toArray(array); }
@Override public Object[] toArray(Object[] array) { if (!_directAccess && isDelayLoad()) { load(); } return super.toArray(array); }
@Override public Object[] toArray(Object[] array) { if (!_directAccess && isDelayLoad()) { load(); } return super.toArray(array); }