Mercurial > hg4j
annotate src/org/tmatesoft/hg/internal/BatchRangeHelper.java @ 575:8bf184c9d733
Issue 43: poor performance with InflaterDataAccess. Phase 1: test existing code, fix defects found
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 16 Apr 2013 16:59:59 +0200 |
parents | 1ee452f31187 |
children |
rev | line source |
---|---|
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012 TMate Software Ltd |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.internal; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import java.util.Arrays; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import java.util.NoSuchElementException; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 /** |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 * Helper to break given range [start..end] (inclusive bounds) to series of ranges, |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 * all but last are of batchSize length, and the last one is at most of batchSize+batchSizeTolerance length. |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 * |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 * Range is [{@link #start()rangeStart}..{@link #end() rangeEnd}], where rangeStart is less or equal to rangeEnd. |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 * |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 * When reverse range iteration is requested, original range is iterated from end to start, but the subranges |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 * boundaries are in natural order. i.e. for 0..100, 10 first subrange would be [91..100], not [100..91]. This |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 * helps clients of this class to get [start()..end()] in natural order regardless of iteration direction. |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 * |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 * Note, this class (and its treatment of inclusive boundaries) is designed solely for use with methods that navigate |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 * revlogs and take (start,end) pair of inclusive range. |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 * |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 * @author Artem Tikhomirov |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 * @author TMate Software Ltd. |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 */ |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 public class BatchRangeHelper { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 private final int rangeCount; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 private final int rangeDelta; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 private final int nextValueDelta; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 private final int firstBoundary, lastBoundary; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 private int rangeIndex, rangeValue, rangeStart, rangeEnd; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 public BatchRangeHelper(int start, int end, int batchSize, boolean reverse) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 this(start, end, batchSize, batchSize/5, reverse); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 public BatchRangeHelper(int start, int end, int batchSize, int batchSizeTolerance, boolean reverse) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 assert end >= start; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 assert start >= 0; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 assert batchSize > 0; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 assert batchSizeTolerance >= 0; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 final int totalElements = end-start+1; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 int batchRangeCount = totalElements / batchSize; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 // batchRangeCount == 0, totalElements > 0 => need at least 1 range |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 if (batchRangeCount == 0 || batchRangeCount*batchSize+batchSizeTolerance < totalElements) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 batchRangeCount++; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
60 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
61 rangeCount = batchRangeCount; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
62 rangeDelta = batchSize-1; // ranges are inclusive, and always grow naturally. |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
63 nextValueDelta = reverse ? -batchSize : batchSize; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 firstBoundary = reverse ? end-rangeDelta : start; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 lastBoundary = reverse ? start : end; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 reset(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
67 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
68 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
69 public boolean hasNext() { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 return rangeIndex < rangeCount; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
71 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
72 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
73 public void next() { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
74 if (!hasNext()) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 throw new NoSuchElementException(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
76 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 rangeStart = rangeValue; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
78 rangeEnd = rangeValue + rangeDelta; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
79 rangeValue += nextValueDelta; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
80 if (++rangeIndex >= rangeCount) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
81 if (nextValueDelta < 0) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
82 // reverse iteration, lastBoundary represents start |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
83 rangeStart = lastBoundary; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
84 } else { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 // lastBoundary represents end |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 rangeEnd = lastBoundary; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
87 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
88 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
89 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
90 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
91 public int start() { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
92 return rangeStart; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
93 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
94 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
95 public int end() { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
96 return rangeEnd; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
97 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
98 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
99 public BatchRangeHelper reset() { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
100 rangeValue = firstBoundary; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
101 rangeIndex = 0; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
102 return this; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
103 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
104 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
105 public int[] toArray() { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
106 int[] rv = new int[rangeCount*2]; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
107 reset(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
108 int i = 0; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
109 while (hasNext()) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
110 next(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
111 rv[i++] = start(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 rv[i++] = end(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
113 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
114 reset(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
115 return rv; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
116 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
117 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
118 public static void main(String[] args) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
119 System.out.println("With remainder within tolerance"); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
120 System.out.println(Arrays.toString(new BatchRangeHelper(0, 102, 10, 4, false).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
121 System.out.println(Arrays.toString(new BatchRangeHelper(0, 102, 10, 4, true).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
122 System.out.println("With remainder out of tolerance"); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
123 System.out.println(Arrays.toString(new BatchRangeHelper(0, 102, 10, 2, false).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 System.out.println(Arrays.toString(new BatchRangeHelper(0, 102, 10, 2, true).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 System.out.println("Range smaller than batch"); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 System.out.println(Arrays.toString(new BatchRangeHelper(1, 9, 10, false).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
127 System.out.println(Arrays.toString(new BatchRangeHelper(1, 9, 10, true).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
128 System.out.println("Range smaller than batch and smaller than tolerance"); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
129 System.out.println(Arrays.toString(new BatchRangeHelper(1, 9, 10, 20, false).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
130 System.out.println(Arrays.toString(new BatchRangeHelper(1, 9, 10, 20, true).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
131 System.out.println("Zero tolerance"); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
132 System.out.println(Arrays.toString(new BatchRangeHelper(0, 100, 10, 0, false).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
133 System.out.println(Arrays.toString(new BatchRangeHelper(0, 100, 10, 0, true).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 System.out.println("Right to boundary"); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
135 System.out.println(Arrays.toString(new BatchRangeHelper(1, 100, 10, false).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 System.out.println(Arrays.toString(new BatchRangeHelper(1, 100, 10, true).toArray())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
137 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
138 } |