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; }
public PStack<T> subList(int start, int end) { return boxed.subList(start, end); } public boolean add(T o) {
public PStack<T> subList(int start) { return boxed.subList(start); }
@Override public PStack<T> subList(int start) { return get().subList(start); }
/** * @param start * @param end * @return * @see org.pcollections.PStack#subList(int, int) */ public PStackX<T> subList(int start, int end) { return this.withStack(stack.subList(start, end)); }
/** * @param start * @return * @see org.pcollections.PStack#subList(int) */ public PStackX<T> subList(int start) { return this.withStack(stack.subList(start)); }
@Override public LinkedListX<T> subList(int start, int end) { return from(get().subList(start,end)); }
assertEqualsAndHash("plusAll should reverse order", stack3.subList(0,stack.size()), stack2); assertEqualsAndHash(stack3.minusAll(stack3), ConsPStack.empty()); assertEqualsAndHash(stack3.minusAll(stack), ConsPStack.empty());
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; }