當前位置: 首頁>>代碼示例>>Java>>正文


Java ArrayDeque.size方法代碼示例

本文整理匯總了Java中java.util.ArrayDeque.size方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrayDeque.size方法的具體用法?Java ArrayDeque.size怎麽用?Java ArrayDeque.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.ArrayDeque的用法示例。


在下文中一共展示了ArrayDeque.size方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMean

import java.util.ArrayDeque; //導入方法依賴的package包/類
/**
 * Get the mean of the data set.
 *
 * @param data the data set.
 * @return the mean of the data set.
 */
private float[] getMean(ArrayDeque<float[]> data) {
    float[] mean = new float[3];

    double[][] values = new double[3][data.size()];
    int index = 0;

    for (float[] axis : data) {
        for (int i = 0; i < axis.length; i++) {
            values[i][index] = axis[i];
        }
        index++;
    }

    for (int i = 0; i < mean.length; i++) {
        mean[i] = (float) StatUtils.percentile(values[i], 50);
    }

    return mean;
}
 
開發者ID:KalebKE,項目名稱:FSensor,代碼行數:26,代碼來源:MedianFilter.java

示例2: getMean

import java.util.ArrayDeque; //導入方法依賴的package包/類
/**
 * Get the mean of the data set.
 *
 * @param data the data set.
 * @return the mean of the data set.
 */
private float[] getMean(ArrayDeque<float[]> data) {
    float[] mean = new float[3];

    for (float[] axis : data) {
        for (int i = 0; i < axis.length; i++) {
            mean[i] += axis[i];
        }
    }

    for (int i = 0; i < mean.length; i++) {
        mean[i] /= data.size();
    }

    return mean;
}
 
開發者ID:KalebKE,項目名稱:FSensor,代碼行數:22,代碼來源:MeanFilter.java

示例3: search

import java.util.ArrayDeque; //導入方法依賴的package包/類
public static int search(byte[] target, byte[] input) {
    Object[] targetB = new Byte[target.length];
    int x = 0;
    while (x < target.length) {
        targetB[x] = target[x];
        ++x;
    }
    int idx = -1;
    ArrayDeque<Byte> q = new ArrayDeque<Byte>(input.length);
    int i = 0;
    while (i < input.length) {
        if (q.size() == targetB.length) {
            Object[] cur = q.toArray(new Byte[0]);
            if (Arrays.equals(cur, targetB)) {
                idx = i - targetB.length;
                break;
            }
            q.pop();
            q.addLast(input[i]);
        } else {
            q.addLast(input[i]);
        }
        ++i;
    }
    return idx;
}
 
開發者ID:thane98,項目名稱:3DSFE-Randomizer,代碼行數:27,代碼來源:BinUtils.java

示例4: onNext

import java.util.ArrayDeque; //導入方法依賴的package包/類
@Override
public final void onNext(T item) {
    T dropped = null;
    synchronized (this) {
        ArrayDeque<T> q = this.queue;
        if (q.size() == capacity) {
            if (dropNewest) {
                dropped = q.pollLast();
            } else {
                dropped = q.pollFirst();
            }
        }
        q.offer(item);
    }
    if (dropped != null) {
        try {
            onDrop.accept(dropped);
        } catch (Throwable ex) {
            upstream.cancel();
            onError(ex);
            return;
        }
    }
    drain();
}
 
開發者ID:akarnokd,項目名稱:Reactive4JavaFlow,代碼行數:26,代碼來源:FolyamOnBackpressureBufferDrop.java

示例5: swapAndSerializeQueuedWrites

import java.util.ArrayDeque; //導入方法依賴的package包/類
/**
 * Swap the two queues of DeferredSerializations and serialize everything in the queue
 * and return the resulting ByteBuffers as an array.
 * @return
 * @throws IOException
 */
final BBContainer[] swapAndSerializeQueuedWrites(final DBBPool pool) throws IOException {
    ArrayDeque<DeferredSerialization> oldlist;
    synchronized (this) {
        if (m_queuedWrites.isEmpty()) {
            return null;
        } else {
            if (m_queuedWrites == m_queuedWrites1) {
                oldlist = m_queuedWrites1;
                m_queuedWrites = m_queuedWrites2;
            }
            else {
                oldlist = m_queuedWrites2;
                m_queuedWrites = m_queuedWrites1;
            }
        }
    }
    final BBContainer results[] = new BBContainer[oldlist.size()];
    int ii = 0;
    DeferredSerialization ds = null;
    int bytesQueued = 0;
    while ((ds = oldlist.poll()) != null) {
        results[ii] = ds.serialize(pool);
        bytesQueued += results[ii].b.remaining();
        assert(results[ii] != null);
        assert(results[ii].b != null);
        ii++;
    }
    updateQueued(bytesQueued, true);
    return results;
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:37,代碼來源:NIOWriteStream.java

示例6: stopWhileSize

import java.util.ArrayDeque; //導入方法依賴的package包/類
private static void stopWhileSize(ArrayDeque<PerformanceNode> d, ThreadPerformance threadPerformance) {
	int s = d.size();
	while (s > 0) {
		PerformanceNode n = d.getFirst();
		if (n.end == 0) {
			n.end = System.nanoTime() - startTime;
			threadPerformance.active.remove(n);
			d.addAll(n.children);
			s = d.size();
		}
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:13,代碼來源:Performance.java

示例7: doIt

import java.util.ArrayDeque; //導入方法依賴的package包/類
/**
 * Your code goes here - see Part0 for an example
 * @param r the reader to read from
 * @param w the writer to write to
 * @throws IOException
 */
public static void doIt(BufferedReader r, PrintWriter w) throws IOException {
	ArrayDeque<String> queue = new ArrayDeque<>();
	for (String line = r.readLine(); line != null; line = r.readLine()) {
		if (queue.size()>=42) {
			if (line.length()==0) {
				w.println(queue.getLast());
			}
			queue.removeLast();
		}
		queue.addFirst(line);
	}
}
 
開發者ID:hughxie,項目名稱:class-code,代碼行數:19,代碼來源:Part3.java

示例8: onNext

import java.util.ArrayDeque; //導入方法依賴的package包/類
@Override
public void onNext(T item) {
    ArrayDeque<T> q = this.queue;
    if (q.size() == n) {
        actual.onNext(q.poll());
    }
    q.offer(item);
}
 
開發者ID:akarnokd,項目名稱:Reactive4JavaFlow,代碼行數:9,代碼來源:FolyamSkipLast.java

示例9: tryOnNext

import java.util.ArrayDeque; //導入方法依賴的package包/類
@Override
public boolean tryOnNext(T item) {
    ArrayDeque<T> q = this.queue;
    boolean b = true;
    if (q.size() == n) {
        b = actual.tryOnNext(q.poll());
    }
    q.offer(item);
    return b;
}
 
開發者ID:akarnokd,項目名稱:Reactive4JavaFlow,代碼行數:11,代碼來源:FolyamSkipLast.java

示例10: onNext

import java.util.ArrayDeque; //導入方法依賴的package包/類
@Override
public final void onNext(T item) {
    ArrayDeque<T> q = this.queue;
    if (q.size() == n) {
        q.poll();
    }
    q.offer(item);
}
 
開發者ID:akarnokd,項目名稱:Reactive4JavaFlow,代碼行數:9,代碼來源:FolyamTakeLast.java

示例11: stop

import java.util.ArrayDeque; //導入方法依賴的package包/類
public static void stop(String tag) {
  if (!enabled.get()) return;
  ThreadPerformance threadPerformance = threadNode.get();
  synchronized (threadPerformance) {
    PerformanceNode last = threadPerformance.active.getLast();
    if (last.tag.equals(tag) && !(last instanceof ThreadPerformance)) {
      last.end = System.nanoTime() - startTime;
      threadPerformance.active.remove(last);
    } else {
      Log.error("Performance: stopping tag '" + tag + "' when the last tag is '" + last.tag + "'");
      PerformanceNode node = null;
      for (PerformanceNode performanceNode : threadPerformance.active) {
        if (performanceNode.tag.equals(tag)) {
          node = performanceNode;
          break;
        }
      }
      if (node == null) {
        Log.error("Performance: tag '" + tag + "' was never started");
        return;
      }
      ArrayDeque<PerformanceNode> d = new ArrayDeque<PerformanceNode>();
      d.add(node);
      while (d.size() > 0) {
        PerformanceNode n = d.getFirst();
        if (n.end == 0) {
          n.end = System.nanoTime() - startTime;
          threadPerformance.active.remove(n);
          d.addAll(n.children);
        }
      }
    }
  }
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:35,代碼來源:Performance.java


注:本文中的java.util.ArrayDeque.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。