本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
}
}
}