List<CommittedChangeList> (final Revision fromIncluding, final Revision toIncluding, final int maxCount, final boolean includingYoungest, final boolean includeOldest) { long young = fromIncluding.getNumber(); young = (young == -1) ? myRevisions.get(myRevisions.size() - 1) : young; final long old = toIncluding.getNumber(); final List<CommittedChangeList> result = new ArrayList<>(); int cnt = -1; // from back for (int i = myRevisions.size() - 1; i >= 0; -- i) { final Long current = myRevisions.get(i); if ((cnt == -1) && (current <= young)) { cnt = 0; } if (cnt >= 0) { ++ cnt; } if ((young > current) || (includingYoungest && (young == current))) { if ((old < current) || (includeOldest && (old == current))) { result.add(createList(current)); } } if (cnt == maxCount) { break; } } return result; }