public E previous() { System.err.println("ConsPStack.listIterator().previous() is inefficient, don't use it!"); next = subList(index-1); // go from beginning... return next.first; }
public ConsPStack<E> subList(final int start) { if(start<0 || start>size) throw new IndexOutOfBoundsException(); if(start==0) return this; return rest.subList(start-1); } }
public E previous() { System.err.println("ConsPStack.listIterator().previous() is inefficient, don't use it!"); next = subList(index-1); // go from beginning... return next.first; }
public ConsPStack<E> subList(final int start) { if(start<0 || start>size) throw new IndexOutOfBoundsException(); if(start==0) return this; return rest.subList(start-1); } }
ConsPStack<E> next = subList(index);
@Override public ConsPStack<E> subList(final int start, final int end) { if(start<0 || end>size || start>end) throw new IndexOutOfBoundsException(); if(end==size) // want a substack return subList(start); // this is faster if(start==end) // want nothing return empty(); if(start==0) // want the current element return new ConsPStack<E>(first, rest.subList(0, end-1)); // otherwise, don't want the current element: return rest.subList(start-1, end-1); }
@Override public ConsPStack<E> subList(final int start, final int end) { if(start<0 || end>size || start>end) throw new IndexOutOfBoundsException(); if(end==size) // want a substack return subList(start); // this is faster if(start==end) // want nothing return empty(); if(start==0) // want the current element return new ConsPStack<E>(first, rest.subList(0, end-1)); // otherwise, don't want the current element: return rest.subList(start-1, end-1); }
ConsPStack<E> next = subList(index);
public ConsPStack<E> subList(final int start) { if(start<0 || start>size) throw new IndexOutOfBoundsException(); if(start==0) return this; return rest.subList(start-1); } }
public ConsPStack<E> subList(final int start) { if (start < 0 || start > size) throw new IndexOutOfBoundsException(); if (start == 0) return this; return rest.subList(start - 1); } }
public E previous() { System.err.println("ConsPStack.listIterator().previous() is inefficient, don't use it!"); next = subList(index-1); // go from beginning... return next.first; }
public E previous() { System.err.println("ConsPStack.listIterator().previous() is inefficient, don't use it!"); next = subList(index - 1); // go from beginning... return next.first; }
@Override public ConsPStack<E> subList(final int start, final int end) { if(start<0 || end>size || start>end) throw new IndexOutOfBoundsException(); if(end==size) // want a substack return subList(start); // this is faster if(start==end) // want nothing return empty(); if(start==0) // want the current element return new ConsPStack<E>(first, rest.subList(0, end-1)); // otherwise, don't want the current element: return rest.subList(start-1, end-1); }
@Override public ConsPStack<E> subList(final int start, final int end) { if (start < 0 || end > size || start > end) throw new IndexOutOfBoundsException(); if (end == size) // want a substack return subList(start); // this is faster if (start == end) // want nothing return empty(); if (start == 0) // want the current element return new ConsPStack<E>(first, rest.subList(0, end - 1)); // otherwise, don't want the current element: return rest.subList(start - 1, end - 1); }
ConsPStack<E> next = subList(index);
ConsPStack<E> next = subList(index);