From d245f6c9e2ba1d2cee64a0ecf886907e94aa4b3f Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 31 Jan 2014 15:26:05 +0900 Subject: Move arrayAsList method to CollectionUtils Change-Id: If7c1eb7c802490f19c5d3b81d714362408daf376 --- .../android/inputmethod/latin/utils/CollectionUtils.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'java/src/com/android/inputmethod/latin/utils/CollectionUtils.java') diff --git a/java/src/com/android/inputmethod/latin/utils/CollectionUtils.java b/java/src/com/android/inputmethod/latin/utils/CollectionUtils.java index cc25102ce..bbfa0f091 100644 --- a/java/src/com/android/inputmethod/latin/utils/CollectionUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/CollectionUtils.java @@ -102,4 +102,19 @@ public final class CollectionUtils { public static SparseArray newSparseArray() { return new SparseArray(); } + + public static ArrayList arrayAsList(final E[] array, final int start, final int end) { + if (array == null) { + throw new NullPointerException(); + } + if (start < 0 || start > end || end > array.length) { + throw new IllegalArgumentException(); + } + + final ArrayList list = newArrayList(end - start); + for (int i = start; i < end; i++) { + list.add(array[i]); + } + return list; + } } -- cgit v1.2.3-83-g751a