folgender Code bei der Aufgabe "simple String Matcher":
Code: Alles auswählen
{
ArrayList<Integer> results = new ArrayList<Integer>();
ArrayList<Integer> candidates = new ArrayList<Integer>();
for (int i = 1; i <= S.length(); i++) {
for (Integer j : candidates) {
if (T.charAt(i - j) != S.charAt(i - 1)) {
candidates.remove(j);
}
}
if (S.charAt(i - 1) == T.charAt(0)) {
candidates.add(i);
}
if (candidates.size() != 0 && candidates.get(0) == (i - T.length()) + 1) {
results.add(candidates.get(0));
candidates.remove(0);
}
}
return results;
}
Der Fehlermeldung kann ich leider nichts entnehmen.Junitreport
Time – 6
Testcount – 5
Failurecount – 1
Ignorerecount – 0
Failurereport
Testheadder – statictest(string_operations.matching.tests_simpleStringMatching.SimpleStringMatchingTest)
Message –
Trace – java.util.ConcurrentModificationException at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901) at java.util.ArrayList$Itr.next(ArrayList.java:851) at string_operations.matching.exercise.simpleStringMatching.SimpleStringMatching.matching(SimpleStringMatching.java:44) at string_operations.matching.tests_simpleStringMatching.SimpleStringMatchingTest.statictest(SimpleStringMatchingTest.java:59) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.lang.Thread.run(Thread.java:745)
Besten Gruß
yi