本文整理了Java中java.util.ArrayDeque.offerFirst()
方法的一些代码示例,展示了ArrayDeque.offerFirst()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArrayDeque.offerFirst()
方法的具体详情如下:
包路径:java.util.ArrayDeque
类名称:ArrayDeque
方法名:offerFirst
[英]Inserts the specified element at the front of this deque.
[中]将指定的元素插入此三角形的前面。
代码示例来源:origin: ReactiveX/RxJava
/**
* Returns a flattened list of Throwables from tree-like CompositeException chain.
* @param t the starting throwable
* @return the list of Throwables flattened in a depth-first manner
*/
public static List<Throwable> flatten(Throwable t) {
List<Throwable> list = new ArrayList<Throwable>();
ArrayDeque<Throwable> deque = new ArrayDeque<Throwable>();
deque.offer(t);
while (!deque.isEmpty()) {
Throwable e = deque.removeFirst();
if (e instanceof CompositeException) {
CompositeException ce = (CompositeException) e;
List<Throwable> exceptions = ce.getExceptions();
for (int i = exceptions.size() - 1; i >= 0; i--) {
deque.offerFirst(exceptions.get(i));
}
} else {
list.add(e);
}
}
return list;
}
代码示例来源:origin: redisson/redisson
/**
* Returns a flattened list of Throwables from tree-like CompositeException chain.
* @param t the starting throwable
* @return the list of Throwables flattened in a depth-first manner
*/
public static List<Throwable> flatten(Throwable t) {
List<Throwable> list = new ArrayList<Throwable>();
ArrayDeque<Throwable> deque = new ArrayDeque<Throwable>();
deque.offer(t);
while (!deque.isEmpty()) {
Throwable e = deque.removeFirst();
if (e instanceof CompositeException) {
CompositeException ce = (CompositeException) e;
List<Throwable> exceptions = ce.getExceptions();
for (int i = exceptions.size() - 1; i >= 0; i--) {
deque.offerFirst(exceptions.get(i));
}
} else {
list.add(e);
}
}
return list;
}
代码示例来源:origin: google/agera
@Override
public boolean offer(@NonNull final Object o) {
if (toReject.contains(o)) {
return false;
}
if (toPrioritize.contains(o)) {
store.offerFirst(o);
} else {
store.offerLast(o);
}
return true;
}
代码示例来源:origin: akarnokd/RxJava2Extensions
boolean push(ExpandDepthSubscriber subscriber) {
synchronized (this) {
ArrayDeque<ExpandDepthSubscriber> q = subscriptionStack;
if (q != null) {
q.offerFirst(subscriber);
return true;
}
return false;
}
}
代码示例来源:origin: org.zeromq/jeromq
@Override
public boolean offerFirst(ZFrame e)
{
return frames.offerFirst(e);
}
代码示例来源:origin: com.github.akarnokd/rxjava2-extensions
boolean push(ExpandDepthSubscriber subscriber) {
synchronized (this) {
ArrayDeque<ExpandDepthSubscriber> q = subscriptionStack;
if (q != null) {
q.offerFirst(subscriber);
return true;
}
return false;
}
}
代码示例来源:origin: us.ihmc/IHMCCommunication
/** {@inheritDoc} */
@Override
public boolean offerFirst(C newCommand)
{
return super.offerFirst(copyAndReturnLocalCommand(newCommand));
}
代码示例来源:origin: de.unijena.bioinf.ms/FastTreeAlign
@Override
public void join(float score, Iterator<T> left, Iterator<T> right, int leftNumber, int rightNumber) {
final ArrayDeque<T> lefts = new ArrayDeque<T>(leftNumber);
final ArrayDeque<T> rights = new ArrayDeque<T>(rightNumber);
while (left.hasNext()) lefts.offerFirst(left.next());
while (right.hasNext()) rights.offerFirst(right.next());
out.print("JOIN (" + lefts.removeFirst() + (lefts.isEmpty() ? ")" : " WITH "));
while (!lefts.isEmpty()) {
out.print(lefts.removeFirst() + (lefts.isEmpty() ? ")" : " WITH "));
}
out.print(" MATCHING: (" + rights.removeFirst() + (rights.isEmpty() ? "" : " WITH "));
while (!rights.isEmpty()) {
out.print(rights.removeFirst() + (rights.isEmpty() ? "" : " WITH "));
}
out.println(" WITH SCORE " + score);
}
}
代码示例来源:origin: akarnokd/RxJava3-preview
/**
* Returns a flattened list of Throwables from tree-like CompositeException chain.
* @param t the starting throwable
* @return the list of Throwables flattened in a depth-first manner
*/
public static List<Throwable> flatten(Throwable t) {
List<Throwable> list = new ArrayList<Throwable>();
ArrayDeque<Throwable> deque = new ArrayDeque<Throwable>();
deque.offer(t);
while (!deque.isEmpty()) {
Throwable e = deque.removeFirst();
if (e instanceof CompositeException) {
CompositeException ce = (CompositeException) e;
List<Throwable> exceptions = ce.getExceptions();
for (int i = exceptions.size() - 1; i >= 0; i--) {
deque.offerFirst(exceptions.get(i));
}
} else {
list.add(e);
}
}
return list;
}
代码示例来源:origin: com.github.akarnokd/rxjava3-common
/**
* Returns a flattened list of Throwables from tree-like CompositeException chain.
* @param t the starting throwable
* @return the list of Throwables flattened in a depth-first manner
*/
public static List<Throwable> flatten(Throwable t) {
List<Throwable> list = new ArrayList<Throwable>();
ArrayDeque<Throwable> deque = new ArrayDeque<Throwable>();
deque.offer(t);
while (!deque.isEmpty()) {
Throwable e = deque.removeFirst();
if (e instanceof CompositeException) {
CompositeException ce = (CompositeException) e;
List<Throwable> exceptions = ce.getExceptions();
for (int i = exceptions.size() - 1; i >= 0; i--) {
deque.offerFirst(exceptions.get(i));
}
} else {
list.add(e);
}
}
return list;
}
代码示例来源:origin: com.github.akarnokd.rxjava3/rxjava3-common
/**
* Returns a flattened list of Throwables from tree-like CompositeException chain.
* @param t the starting throwable
* @return the list of Throwables flattened in a depth-first manner
*/
public static List<Throwable> flatten(Throwable t) {
List<Throwable> list = new ArrayList<Throwable>();
ArrayDeque<Throwable> deque = new ArrayDeque<Throwable>();
deque.offer(t);
while (!deque.isEmpty()) {
Throwable e = deque.removeFirst();
if (e instanceof CompositeException) {
CompositeException ce = (CompositeException) e;
List<Throwable> exceptions = ce.getExceptions();
for (int i = exceptions.size() - 1; i >= 0; i--) {
deque.offerFirst(exceptions.get(i));
}
} else {
list.add(e);
}
}
return list;
}
代码示例来源:origin: one.util/streamex
if (s.payload == null)
break;
res.offerFirst(s.payload);
s = s.prefix;
代码示例来源:origin: de.unijena.bioinf.ms/FastTreeAlign
private boolean traceMatch(Tree<T> u, Tree<T> v, float opt, final HashTable<T> D,
final int A, final int B, final List<Tree<T>> As, final List<Tree<T>> Bs) {
for (Tree<T> a : As) {
final int A_ = A & ~a.key;
for (Tree<T> b : Bs) {
final int B_ = B & ~b.key;
final float pre = /*(A_ == 0 || B_ == 0) ? 0 :*/ D.get(A_, B_);
//if (A_ > 0 && B_ > 0 && pre == 0) continue;
final float matchScore = scoring.match(a.label, b.label);
final float subtreeScore = tables.get(a.index, b.index).getScore();
float score = subtreeScore + pre + matchScore;
if (score >= opt) {
assert Math.abs(score - opt) < 1e-6 : score + " from match is greater than opt: " + opt;
tracer.match(matchScore, a.label, b.label);
if (pre > 0) traceQueue.offerFirst(new MultiJoinTraceItem<T>(u, v, A_, B_));
if (a.degree() > 0 && b.degree() > 0 && subtreeScore > 0) {
addTraceItemFor(a, b, subtreeScore);
}
return true;
}
}
}
return false;
}
代码示例来源:origin: stackoverflow.com
return arrayDeque.offerFirst(e);
代码示例来源:origin: de.unijena.bioinf.ms/FastTreeAlign
private boolean addTraceItemFor(Tree<T> u, Tree<T> v, int A, int B, float opt) {
final HashTable<T> D = tables.get(u.index, v.index);
final IntPairFloatIterator iter = D.each();
while (iter.hasNext()) {
iter.next();
if (iter.getValue() >= opt) {
if ((iter.getLeft() & A) == iter.getLeft() && (iter.getRight() & B) == iter.getRight()) {
assert iter.getValue() == opt;
traceQueue.offerFirst(new MultiJoinTraceItem<T>(u, v, iter.getLeft(), iter.getRight()));
return true;
}
}
}
assert false;
return false;
}
代码示例来源:origin: de.unijena.bioinf.ms/FastTreeAlign
private boolean addTraceItemFor(Tree<T> u, Tree<T> v, short l, short r, int A, int B, float opt) {
final HashTable<T> D = tables.get(u.index, v.index);
final IntPairFloatIterator iter = D.eachInJoin(l, r);
while (iter.hasNext()) {
iter.next();
if (iter.getValue() >= opt) {
if ((iter.getLeft() & A) == iter.getLeft() && (iter.getRight() & B) == iter.getRight()) {
assert iter.getValue() == opt;
traceQueue.offerFirst(new MultiJoinTraceItem<T>(u, v, iter.getLeft(), iter.getRight(), l, r));
return true;
}
}
}
assert false;
return false;
}
内容来源于网络,如有侵权,请联系作者删除!