提交 b91fcf2b authored 作者: Noel Grandin's avatar Noel Grandin

Iterator says we need to do the work in next()

and add remove() method for Java1.7 compat
上级 bcf436f8
......@@ -204,24 +204,27 @@ public class ValueHashMap<V> extends HashBase {
}
private final class EntryIterator implements Iterator<Map.Entry<Value, V>> {
int keysIndex = -1;
private int keysIndex = -1;
private int left = size;
@Override
public boolean hasNext() {
if (keysIndex >= keys.length)
return false;
return left > 0;
}
@Override
public Map.Entry<Value, V> next() {
left--;
do {
keysIndex++;
if (keysIndex >= keys.length)
return false;
if (keys[keysIndex] != null && keys[keysIndex] != ValueNull.DELETED)
return true;
return new DataUtils.MapEntry<Value, V>(keys[keysIndex], values[keysIndex]);
} while (true);
}
@Override
public Map.Entry<Value, V> next() {
return new DataUtils.MapEntry<Value, V>(keys[keysIndex], values[keysIndex]);
public void remove() {
throw new UnsupportedOperationException();
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论