From ff17455baa7ab8ea713412e6ee5e777ad524f498 Mon Sep 17 00:00:00 2001 From: Marcin Olawski Date: Sat, 7 Feb 2015 21:12:48 +0100 Subject: [PATCH] Add Arrays.fill(* a,int start,int stop,* value). --- classpath/java/util/Arrays.java | 75 +++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/classpath/java/util/Arrays.java b/classpath/java/util/Arrays.java index 2357103eca..b60ef7d0f9 100644 --- a/classpath/java/util/Arrays.java +++ b/classpath/java/util/Arrays.java @@ -485,29 +485,69 @@ public class Arrays { }; } + private static void checkRange(int len, int start, int stop) { + if (start < 0) { + throw new ArrayIndexOutOfBoundsException(start); + } + if (stop > len) { + throw new ArrayIndexOutOfBoundsException(stop); + } + if (start > stop) { + throw new IllegalArgumentException("start(" + start + ") > stop(" + stop + ")"); + } + } + public static void fill(int[] array, int value) { for (int i=0;i void fill(T[] array, T value) { for (int i=0;i void fill(T[] array, int start, int stop, T value) { + checkRange(array.length, start, stop); + for (int i=start;i newLength ? newLength : array.length;