mirror of
https://github.com/processing/processing4.git
synced 2026-02-26 08:44:39 +01:00
refinements/simplification
This commit is contained in:
@@ -423,10 +423,13 @@ public class FloatList implements Iterable<Float> {
|
||||
}
|
||||
|
||||
|
||||
private String exceptionText(int count, int index, String method){
|
||||
return "The list size is "+count+". Trying to "+method+" the element at "+index+" which does not exist.";
|
||||
private void boundsProblem(int index, String method) {
|
||||
final String msg = String.format("The list size is %d. " +
|
||||
"You cannot %s() to element %d.", count, method, index);
|
||||
throw new ArrayIndexOutOfBoundsException(msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief Add to a value
|
||||
@@ -435,7 +438,7 @@ public class FloatList implements Iterable<Float> {
|
||||
if (index < count) {
|
||||
data[index] += amount;
|
||||
} else {
|
||||
throw new ArrayIndexOutOfBoundsException(exceptionText(count, index, "add"));
|
||||
boundsProblem(index, "add");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,7 +451,7 @@ public class FloatList implements Iterable<Float> {
|
||||
if (index < count) {
|
||||
data[index] -= amount;
|
||||
} else {
|
||||
throw new ArrayIndexOutOfBoundsException(exceptionText(count, index, "sub"));
|
||||
boundsProblem(index, "sub");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +464,7 @@ public class FloatList implements Iterable<Float> {
|
||||
if (index < count) {
|
||||
data[index] *= amount;
|
||||
} else {
|
||||
throw new ArrayIndexOutOfBoundsException(exceptionText(count, index, "mult"));
|
||||
boundsProblem(index, "mult");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +477,7 @@ public class FloatList implements Iterable<Float> {
|
||||
if (index < count) {
|
||||
data[index] /= amount;
|
||||
} else {
|
||||
throw new ArrayIndexOutOfBoundsException(exceptionText(count, index, "div"));
|
||||
boundsProblem(index, "div");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -407,10 +407,14 @@ public class IntList implements Iterable<Integer> {
|
||||
data[index]++;
|
||||
}
|
||||
|
||||
private String exceptionText(int count, int index, String method){
|
||||
return "The list size is "+count+". Trying to "+method+" the element at "+index+" which does not exist.";
|
||||
|
||||
private void boundsProblem(int index, String method) {
|
||||
final String msg = String.format("The list size is %d. " +
|
||||
"You cannot %s() to element %d.", count, method, index);
|
||||
throw new ArrayIndexOutOfBoundsException(msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intlist:method
|
||||
* @brief Add to a value
|
||||
@@ -419,7 +423,7 @@ public class IntList implements Iterable<Integer> {
|
||||
if (index < count) {
|
||||
data[index] += amount;
|
||||
} else {
|
||||
throw new IndexOutOfBoundsException(exceptionText(count, index, "add"));
|
||||
boundsProblem(index, "add");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +435,7 @@ public class IntList implements Iterable<Integer> {
|
||||
if (index < count) {
|
||||
data[index] -= amount;
|
||||
} else {
|
||||
throw new IndexOutOfBoundsException(exceptionText(count, index, "sub"));
|
||||
boundsProblem(index, "sub");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +447,7 @@ public class IntList implements Iterable<Integer> {
|
||||
if (index < count) {
|
||||
data[index] *= amount;
|
||||
} else {
|
||||
throw new IndexOutOfBoundsException(exceptionText(count, index, "mult"));
|
||||
boundsProblem(index, "mult");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,7 +459,7 @@ public class IntList implements Iterable<Integer> {
|
||||
if (index < count) {
|
||||
data[index] /= amount;
|
||||
} else {
|
||||
throw new IndexOutOfBoundsException(exceptionText(count, index, "div"));
|
||||
boundsProblem(index, "div");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user