diff src/org/tmatesoft/hg/internal/IntVector.java @ 680:58a6900f845d

Blame: alternative strategy to handle merge revisions: map(diff(p1->base->p2)) to understand merge intentions better
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sun, 21 Jul 2013 17:15:34 +0200
parents f41dd9a3b8af
children
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/IntVector.java	Sat Jul 20 17:40:52 2013 +0200
+++ b/src/org/tmatesoft/hg/internal/IntVector.java	Sun Jul 21 17:15:34 2013 +0200
@@ -24,7 +24,7 @@
  * @author Artem Tikhomirov
  * @author TMate Software Ltd.
  */
-public class IntVector {
+public class IntVector implements Cloneable {
 	
 	private int[] data;
 	private final int increment;
@@ -57,7 +57,17 @@
 			data[count++] = v;
 		}
 	}
-	
+
+	public void addAll(IntVector other) {
+		final int otherLen = other.count;
+		if (count + otherLen > data.length) {
+			grow(count + otherLen);
+		}
+		for (int i = 0; i < otherLen; i++) {
+			data[count++] = other.data[i];
+		}
+	}
+
 	public int get(int i) {
 		if (i < 0 || i >= count) {
 			throw new IndexOutOfBoundsException(String.format("Index: %d, size: %d", i, count));
@@ -126,6 +136,15 @@
 	public String toString() {
 		return String.format("%s[%d]", IntVector.class.getSimpleName(), size());
 	}
+	
+	@Override
+	public IntVector clone() {
+		try {
+			return (IntVector) super.clone();
+		} catch (CloneNotSupportedException ex) {
+			throw new Error(ex);
+		}
+	}
 
 	/**
 	 * Use only when this instance won't be used any longer