Ranides Atterwim 4 лет назад
Родитель
Сommit
0b57f56673

+ 3 - 0
assira.commons/src/main/java/net/ranides/assira/collection/lookups/ArrayLookup.java

@@ -187,6 +187,9 @@ public class ArrayLookup<K> extends ALookup<K> implements BlockMap<K,Integer> {
         if(n > capacity()) {
             return false;
         }
+        if(n<size) {
+            throw new IllegalArgumentException(String.format("n= %d is too small (size=%d)", n, size));
+        }
         this.keys = ArrayUtils.slice(keys, 0, n);
         this.vars = ArrayUtils.slice(vars, 0, n);
         return true;

+ 3 - 0
assira.commons/src/main/java/net/ranides/assira/collection/maps/IntArrayMap.java

@@ -88,6 +88,9 @@ public class IntArrayMap<V> extends AIntMap<V> implements BlockMap<Integer, V> {
         if(n > capacity()) {
             return false;
         }
+        if(n<size) {
+            throw new IllegalArgumentException(String.format("n= %d is too small (size=%d)", n, size));
+        }
         this.keys = ArrayUtils.slice(keys, 0, n);
         this.vars = ArrayUtils.slice(vars, 0, n);
         return true;