public E peek() { if(size()==0) return null; return front.get(0); }
public E peek() { if(size()==0) return null; return front.get(0); }
public Entry<Integer,V> next() { IntTree<V> node = stack.get(0); final Entry<Integer,V> result = new SimpleImmutableEntry<Integer,V>(key, node.value); // find next node. // we've already done everything smaller, // so try least larger node: if(node.right.size>0) // we can descend to the right gotoMinOf(node.right); else // can't descend to the right -- try ascending to the right while (true) { // find current node's least larger ancestor, if any key -= node.key; // revert to parent's key stack = stack.subList(1); // climb up to parent // if parent was larger than child or there was no parent, we're done: if(node.key<0 || stack.size()==0) break; // otherwise parent was smaller -- try its parent: node = stack.get(0); } return result; }
public Entry<Integer,V> next() { IntTree<V> node = stack.get(0); final Entry<Integer,V> result = new SimpleImmutableEntry<Integer,V>(key, node.value); // find next node. // we've already done everything smaller, // so try least larger node: if(node.right.size>0) // we can descend to the right gotoMinOf(node.right); else // can't descend to the right -- try ascending to the right while (true) { // find current node's least larger ancestor, if any key -= node.key; // revert to parent's key stack = stack.subList(1); // climb up to parent // if parent was larger than child or there was no parent, we're done: if(node.key<0 || stack.size()==0) break; // otherwise parent was smaller -- try its parent: node = stack.get(0); } return result; }
/** * @param index * @return * @see java.util.List#get(int) */ public T get(int index) { return stack.get(index); }
public T get(int index) { return boxed.get(index); }
public E peek() { if (size() == 0) return null; return front.get(0); }
public E peek() { if(size()==0) return null; return front.get(0); }
@Override public T get(int index) { return get().get(index); }
public T peek() { return stack.isEmpty() ? null : stack.get(0); }
public boolean isSequential() { if (execList.size() == 0) return true; if (execList.size() == 1 && execList.get(0) == null) return true; return false; }
public boolean isSequential(){ if( execList.size()==0) return true; if(execList.size()==1 && execList.get(0)==null) return true; return false; } public <T> ExecutionPipeline peek(Consumer<T> c){
assertEquals("first element should be most recently added", s, stack.get(0)); assertTrue("stack.plus(x).contains(x) should be true!", stack.contains(s));
public <X extends Throwable,T> ExecutionPipeline exceptionally(Function<X,T> fn){ if(functionList.size()>0){ Function before = functionList.get(functionList.size()-1); Function except = t-> { try{ return before.apply(t); }catch(Throwable e){ return fn.apply((X)e); } }; return new ExecutionPipeline(swapFn(except),execList,firstRecover,onFail); } return new ExecutionPipeline(functionList,execList,addFirstRecovery(fn),onFail); } public <X extends Throwable,T> ExecutionPipeline whenComplete(BiConsumer<T,X> fn){
public <X extends Throwable, T> ExecutionPipeline exceptionally(final Function<? super X, ? extends T> fn) { if (functionList.size() > 0) { final Function before = functionList.get(functionList.size() - 1); final Function except = t -> { try { return before.apply(t); } catch (final Throwable e) { return fn.apply((X) e); } }; return new ExecutionPipeline( swapFn(except), execList, firstRecover, onFail); } return new ExecutionPipeline( functionList, execList, addFirstRecovery(fn), onFail); }
public T yield(ExecutionState state) { Expansion head = generators.get(0); return new Yield<T>(generators) .process(state.contextualExecutor, HashTreePMap.empty(), head .getFunction().executeAndSetContext(HashTreePMap.empty()), head .getName(), 1); }
private PStack<Function> swapFn(final Function fn) { if (functionList.size() == 0) return functionList.plus(fn); functionList.get(functionList.size() - 1); final PStack<Function> removed = functionList.minus(functionList.size() - 1); return removed.plus(removed.size(), fn); }
private PStack<Function> swapFn(Function fn){ if(functionList.size()==0) return functionList.plus(fn); Function before = functionList.get(functionList.size()-1); PStack<Function> removed = functionList.minus(functionList.size()-1); return removed.plus(removed.size(),fn); } private PStack<Function> swapComposeFn(Function fn){
/** * Remove KList artifacts from parsing only when it contains a single element. */ @Override public Either<Set<ParseFailedException>, Term> apply(KList node) { Either<Set<ParseFailedException>, Term> res = super.apply(node); if (res.isRight() && ((KList) res.right().get()).items().size() == 1) return Right.apply(((KList) res.right().get()).items().get(0)); else return res; } }