当前位置: 首页>>代码示例>>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;未经允许,请勿转载。