【发布时间】:2018-03-26 15:15:10
【问题描述】:
我一直在开发的数据库函数依赖算法遇到问题。我正在尝试计算给定格子的当前级别和列头列表(不是真正相关的)的函数依赖关系。
我正在尝试遍历字符串标题列表,以及遍历每个字符串的字符。以此推理,然后我使用这些值从映射中的List<String> 值中删除一个字符串。 Map 的结构为<String, List<String>>,我想简单地从HashMap 的List<String> 值中删除一个值。 colHeads 是 List<String>。
当我开始循环遍历列表时出现 ConcurrentModificationException:
for (String x: level) {
for (char a : x.toCharArray()) {
if (cPlusHash.get(x).contains(Character.toString(a))) {
if (checkFD(Arrays.asList(x.replace("a", "")), Arrays.asList(Character.toString(a)))){
fds.add(x.replace("a", "") +", "+ a );
cPlusHash.remove(x, Character.toString(a));
for (char j : x.toCharArray()) {
if (colHeads.contains(Character.toString(j))) {
colHeads.remove(Character.toString(j));
}
}
for (String b : colHeads) {
if (cPlusHash.get(x).contains(b)) {
cPlusHash.remove(x, b);
}
}
}
}
}
我在这个 sn-p 代码的第一行得到了错误。我很困惑,因为我实际上并没有尝试修改我正在迭代的 List 的值。
【问题讨论】:
标签: java exception arraylist hashmap concurrentmodification