Changeset 6717 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-01-17T21:33:44+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/CopyList.java
r6380 r6717 3 3 4 4 import java.util.AbstractList; 5 import java.util.Arrays; 5 6 import java.util.ConcurrentModificationException; 6 7 import java.util.Iterator; … … 129 130 } 130 131 131 @SuppressWarnings("unchecked")132 132 private void ensureCapacity(int target) { 133 133 modCount++; 134 134 if (target > array.length) { 135 E[] old = array;136 137 135 int newCapacity = Math.max(target, (array.length * 3)/2 + 1); 138 array = (E[]) new Object[newCapacity]; 139 System.arraycopy(old, 0, array, 0, size); 136 array = Arrays.copyOf(array, newCapacity); 140 137 pristine = false; 141 138 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6661 r6717 952 952 return result; 953 953 } 954 955 /** 956 * Adds the given item at the end of a new copy of given array. 957 * @param array The source array 958 * @param item The item to add 959 * @return An extended copy of {@code array} containing {@code item} as additional last element 960 * @since 6717 961 */ 962 public static <T> T[] addInArrayCopy(T[] array, T item) { 963 T[] biggerCopy = Arrays.copyOf(array, array.length + 1); 964 biggerCopy[array.length] = item; 965 return biggerCopy; 966 } 954 967 }
Note: See TracChangeset
for help on using the changeset viewer.