/** * Returns the number of elements in this ExclusiveRange. * * @return the number of elements in this ExclusiveRange. */ @Pure public int size() { return (isEmpty()) ? 0 : Math.abs(last - first) + 1; }
/** * Returns the number of elements in this ExclusiveRange. * * @return the number of elements in this ExclusiveRange. */ @Pure public int size() { return (isEmpty()) ? 0 : Math.abs(last - first) + 1; }
/** * Checks whether this contains the given number, i.e. whether the iterator will yield the number. This is different * from interval containment: <code>0..2.by(2)</code> will <em>not</em> contain 1. * * @param number * the number to be checked for containment. * @return whether this sequence contains the given number or not. */ @Pure public boolean contains(int number) { if (isEmpty()) return false; if(step == -1) return number <= first && number >= last; else return number >= first && number <= last; }
/** * Checks whether this contains the given number, i.e. whether the iterator will yield the number. This is different * from interval containment: <code>0..2.by(2)</code> will <em>not</em> contain 1. * * @param number * the number to be checked for containment. * @return whether this sequence contains the given number or not. */ @Pure public boolean contains(int number) { if (isEmpty()) return false; if(step == -1) return number <= first && number >= last; else return number >= first && number <= last; }
/** * @return a read-only {@link ListIterator} for this. */ @Override @Pure public ListIterator<Integer> iterator() { return isEmpty() ? EMPTY_LIST_ITERATOR : new RangeIterator(); }
/** * @return a read-only {@link ListIterator} for this. */ @Override @Pure public ListIterator<Integer> iterator() { return isEmpty() ? EMPTY_LIST_ITERATOR : new RangeIterator(); }