@Override @SuppressWarnings("unchecked") public Flow<T> sort() { if (values.length < 2) return this; List<Comparable> newValues = (List<Comparable>) toMutableList(); Collections.sort(newValues); return new ArrayFlow<T>((List<T>) newValues); }
@Override public synchronized Flow<T> rest() { if (rest == null) rest = buildRest(); return rest; }
@Override public Iterator<T> iterator() { return toList().iterator(); }
@Override public Flow<T> reverse() { if (values.length < 2) return this; List<T> newValues = new ArrayList<T>(); newValues.addAll(Arrays.asList(values)); Collections.reverse(newValues); return new ArrayFlow<T>(newValues); }
/** Creates an ArrayFlow from the values in the other flow. */ ArrayFlow(Flow<T> flow) { this(toMutableList(flow)); }
@Override public Flow<T> reverse() { if (values.length < 2) return this; List<T> newValues = new ArrayList<T>(); newValues.addAll(Arrays.asList(values)); Collections.reverse(newValues); return new ArrayFlow<T>(newValues); }
/** Creates an ArrayFlow from the values in the other flow. */ ArrayFlow(Flow<T> flow) { this(toMutableList(flow)); }
@Override public Flow<T> sort(Comparator<T> comparator) { assert comparator != null; if (values.length < 2) return this; List<T> newValues = toMutableList(); Collections.sort(newValues, comparator); return new ArrayFlow<T>(newValues); }
@Override public Flow<T> take(int length) { if (length < 1) return F.emptyFlow(); return new ArrayFlow<T>(values, start, Math.min(count, length)); }
@Override public Iterator<T> iterator() { return toList().iterator(); }
@Override public synchronized Flow<T> rest() { if (rest == null) rest = buildRest(); return rest; }
@Override public Flow<T> sort(Comparator<T> comparator) { assert comparator != null; if (values.length < 2) return this; List<T> newValues = toMutableList(); Collections.sort(newValues, comparator); return new ArrayFlow<T>(newValues); }
@Override public Flow<T> drop(int length) { assert length >= 0; if (length == 0) return this; if (length >= count) return F.emptyFlow(); return new ArrayFlow<T>(values, start + length, count - length); } }
@Override @SuppressWarnings("unchecked") public Flow<T> sort() { if (values.length < 2) return this; List<Comparable> newValues = (List<Comparable>) toMutableList(); Collections.sort(newValues); return new ArrayFlow<T>((List<T>) newValues); }