annotate src/org/tmatesoft/hg/internal/IntSliceSeq.java @ 679:19f5167c2155

HgParentChildMap: deduce common ancestor functionality
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 20 Jul 2013 17:40:52 +0200
parents cce0387c6041
children 58a6900f845d
rev   line source
674
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2013 TMate Software Ltd
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.internal;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
19 import java.util.Iterator;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20 import java.util.NoSuchElementException;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
21
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22 /**
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 *
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 * @author Artem Tikhomirov
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25 * @author TMate Software Ltd.
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 */
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 public final class IntSliceSeq implements Iterable<IntTuple> {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 private final IntVector slices;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 private final int slice;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31 public IntSliceSeq(int sliceSize) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32 // initial size/grow values are pure guess
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 this(sliceSize, 10, 5);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 public IntSliceSeq(int sliceSize, int initialSlices, int slicesToGrow) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37 slices = new IntVector(sliceSize * initialSlices, sliceSize*slicesToGrow);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 slice = sliceSize;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 public IntSliceSeq add(int... values) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 checkValues(values);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43 slices.add(values);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
44 return this;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47 public IntSliceSeq set(int sliceIndex, int... values) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48 checkValues(values);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49 for (int i = 0, j = sliceIndex*slice; i < slice; i++,j++) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 slices.set(j, values[i]);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
51 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
52 return this;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
53 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
54
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
55 public IntTuple get(int sliceIndex) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
56 checkArgRange(size(), sliceIndex);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
57 return new IntTuple(slice).set(slices, sliceIndex*slice);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
58 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
59
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60 public int get(int sliceIndex, int valueIndex) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 checkArgRange(size(), sliceIndex);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
62 checkArgRange(slice, valueIndex);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
63 return slices.get(sliceIndex*slice + valueIndex);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
64 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
65
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
66 public int size() {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
67 return slices.size() / slice;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
68 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
69
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
70 public int sliceSize() {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
71 return slice;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
72 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
73
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
74 public void clear() {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
75 slices.clear();
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
76 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
77
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
78 public IntTuple last() {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
79 int lastElementIndex = (size() - 1);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
80 if (lastElementIndex < 0) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
81 throw new NoSuchElementException();
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
82 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 return get(lastElementIndex);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
84 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
85
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
86 public Iterator<IntTuple> iterator() {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
87 return new Iterator<IntTuple>() {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
88 private final IntTuple t = new IntTuple(slice);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
89 private int next = 0;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
90
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
91 public boolean hasNext() {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
92 return next < size();
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
93 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
94
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
95 public IntTuple next() {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
96 return t.set(slices, next++*slice);
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
97 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
98
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
99 public void remove() {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
100 throw new UnsupportedOperationException();
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
101 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
102 };
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
103 }
679
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
104
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
105 @Override
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
106 public String toString() {
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
107 StringBuilder sb = new StringBuilder();
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
108 for (int i = 0; i < size(); i++) {
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
109 sb.append('(');
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
110 for (int j = 0; j < slice; j++) {
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
111 sb.append(slices.get(i*slice + j));
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
112 sb.append(',');
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
113 }
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
114 sb.setLength(sb.length() - 1);
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
115 sb.append(')');
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
116 sb.append(' ');
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
117 }
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
118 return sb.toString();
19f5167c2155 HgParentChildMap: deduce common ancestor functionality
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 674
diff changeset
119 }
674
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
120
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
121 private void checkArgRange(int rangeSize, int index) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
122 if (index >= 0 && index < rangeSize) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
123 return;
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
124 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
125 throw new IllegalArgumentException(String.valueOf(index));
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
126 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
127 private void checkValues(int[] values) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
128 if (values == null || values.length != slice) {
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
129 throw new IllegalArgumentException(String.valueOf(values == null ? values : values.length));
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
130 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
131 }
cce0387c6041 Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
132 }