Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/IntTuple.java @ 674:cce0387c6041
Introduced dedicated IntSliceSeq/IntTuple in place of IntArray with subsequences
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 17 Jul 2013 15:40:51 +0200 |
parents | |
children | 1c49c0cee540 |
comparison
equal
deleted
inserted
replaced
673:545b1d4cc11d | 674:cce0387c6041 |
---|---|
1 /* | |
2 * Copyright (c) 2013 TMate Software Ltd | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; version 2 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * For information on how to redistribute this software under | |
14 * the terms of a license other than GNU General Public License | |
15 * contact TMate Software at support@hg4j.com | |
16 */ | |
17 package org.tmatesoft.hg.internal; | |
18 | |
19 /** | |
20 * Tuple of integers | |
21 * @author Artem Tikhomirov | |
22 * @author TMate Software Ltd. | |
23 */ | |
24 public final class IntTuple implements Cloneable { | |
25 private final int size; | |
26 private IntVector v; | |
27 private int start; | |
28 | |
29 IntTuple(int length) { | |
30 size = length; | |
31 } | |
32 /*package*/IntTuple set(IntVector vect, int index) { | |
33 v = vect; | |
34 start = index; | |
35 return this; | |
36 } | |
37 | |
38 public int size() { | |
39 return size; | |
40 } | |
41 | |
42 public int at(int index) { | |
43 if (index < size) { | |
44 return v.get(start + index); | |
45 } | |
46 throw new IllegalArgumentException(String.valueOf(index)); | |
47 } | |
48 | |
49 public IntTuple clone() { | |
50 try { | |
51 return (IntTuple) super.clone(); | |
52 } catch (CloneNotSupportedException ex) { | |
53 throw new Error(ex); | |
54 } | |
55 } | |
56 } |