diff src/org/tmatesoft/hg/internal/IntVector.java @ 329:694ebabb5cb3

Refactor revlog patch mechanism, towards patch merging
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 13 Oct 2011 03:30:50 +0200
parents a674b8590362
children 15b406c7cd9d
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/IntVector.java	Wed Oct 05 07:13:57 2011 +0200
+++ b/src/org/tmatesoft/hg/internal/IntVector.java	Thu Oct 13 03:30:50 2011 +0200
@@ -57,6 +57,15 @@
 	public int size() {
 		return count;
 	}
+	
+	public void clear() {
+		count = 0;
+	}
+	
+	public void trimToSize() {
+		data = toArray(true);
+	}
+
 
 	public int[] toArray() {
 		int[] rv = new int[count];
@@ -77,8 +86,7 @@
 
 	private void grow() {
 		if (increment == 0) {
-			// throw specific exception right away
-			return;
+			throw new UnsupportedOperationException("This vector is not allowed to expand");
 		}
 		int newCapacity = increment < 0 ? data.length << 1 : data.length + increment;
 		assert newCapacity > 0 && newCapacity != data.length : newCapacity;