diff src/org/tmatesoft/hg/internal/IntVector.java @ 552:45751456b471

Annotate file changes through few revisions, walking either direction (old to new and vice versa)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 20 Feb 2013 22:23:50 +0100
parents 4ea0351ca878
children d3c71498919c
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/IntVector.java	Wed Feb 20 18:19:52 2013 +0100
+++ b/src/org/tmatesoft/hg/internal/IntVector.java	Wed Feb 20 22:23:50 2013 +0100
@@ -49,7 +49,7 @@
 	
 	public void add(int... values) {
 		if (count + values.length > data.length) {
-			grow(count + values.length - data.length);
+			grow(count + values.length);
 		}
 		for (int v : values) {
 			data[count++] = v;
@@ -92,6 +92,19 @@
 		System.arraycopy(data, 0, rv, 0, count);
 		return rv;
 	}
+	
+	public void reverse() {
+		for (int a = 0, b = count-1; a < b; a++, b--) {
+			int t = data[b];
+			data[b] = data[a];
+			data[a] = t;
+		}
+	}
+
+	@Override
+	public String toString() {
+		return String.format("%s[%d]", IntVector.class.getSimpleName(), size());
+	}
 
 	/**
 	 * Use only when this instance won't be used any longer
@@ -117,9 +130,4 @@
 		System.arraycopy(data, 0, newData, 0, count);
 		data = newData;
 	}
-	
-	@Override
-	public String toString() {
-		return String.format("%s[%d]", IntVector.class.getSimpleName(), size());
-	}
 }