From 560ea5ea64e2a82fa4aaf9f2fb9f4329766f65bb Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 18 Mar 2003 19:50:49 +0000 Subject: [PATCH] check for ConcurrentModificationException in our iterator's remove(). git-svn-id: https://samskivert.googlecode.com/svn/trunk@1070 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/util/IntIntMap.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/IntIntMap.java b/projects/samskivert/src/java/com/samskivert/util/IntIntMap.java index 6e8d330e..b5ebd1dd 100644 --- a/projects/samskivert/src/java/com/samskivert/util/IntIntMap.java +++ b/projects/samskivert/src/java/com/samskivert/util/IntIntMap.java @@ -1,5 +1,5 @@ // -// $Id: IntIntMap.java,v 1.5 2003/03/10 04:59:20 ray Exp $ +// $Id: IntIntMap.java,v 1.6 2003/03/18 19:50:49 ray Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -212,11 +212,19 @@ public class IntIntMap _returnKeys = returnKeys; } - public boolean hasNext () - { + /** + * Check for concurrent modifications. + */ + protected void checkMods () + { if (this._modCount != IntIntMap.this._modCount) { throw new ConcurrentModificationException("IntIntMapIterator"); } + } + + public boolean hasNext () + { + checkMods(); // if we're pointing to an entry, we've got more entries if (_next != null) { @@ -251,6 +259,8 @@ public class IntIntMap public void remove () { + checkMods(); + if (_prev == null) { throw new IllegalStateException("IntIntMapIterator"); }