summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2013-04-03 23:55:16 -0700
committerHarvey Harrison <[email protected]>2013-04-03 23:55:16 -0700
commitd721e4f356d2cb272b0eb47829220a5b2b23c2dc (patch)
treeee7ad12dec3ca9a3428c0091484411a811f149c5 /src
parentd70f55e63c38331486249bdfdbd1234ce4bbeb09 (diff)
gluegen: use enhanced for-loops in ArrayHashSet
Fixes an infinite loop in addAll due to the following line: mod = mod || add(iter.next()) ; After the first successful add, mod will be true and thereafter iter.next will never be called again, due to || shortcutting. the loop will then run forever as any further elements will never be taken from the iterator, so hasNext will always be true. Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/java/com/jogamp/common/util/ArrayHashSet.java19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/java/com/jogamp/common/util/ArrayHashSet.java b/src/java/com/jogamp/common/util/ArrayHashSet.java
index 630e2af..fe5ade8 100644
--- a/src/java/com/jogamp/common/util/ArrayHashSet.java
+++ b/src/java/com/jogamp/common/util/ArrayHashSet.java
@@ -168,8 +168,8 @@ public class ArrayHashSet<E>
*/
public final boolean addAll(Collection<? extends E> c) {
boolean mod = false;
- for (Iterator<? extends E> iter = c.iterator(); iter.hasNext(); ) {
- mod = mod || add(iter.next()) ;
+ for (E o : c) {
+ mod |= add(o);
}
return mod;
}
@@ -195,8 +195,8 @@ public class ArrayHashSet<E>
* otherwise false.
*/
public final boolean containsAll(Collection<?> c) {
- for (Iterator<?> iter = c.iterator(); iter.hasNext(); ) {
- if (! this.contains(iter.next()) ) {
+ for (Object o : c) {
+ if (!this.contains(o)) {
return false;
}
}
@@ -213,8 +213,8 @@ public class ArrayHashSet<E>
*/
public final boolean removeAll(Collection<?> c) {
boolean mod = false;
- for (Iterator<?> iter = c.iterator(); iter.hasNext(); ) {
- mod = this.remove(iter.next()) || mod;
+ for (Object o : c) {
+ mod |= this.remove(o);
}
return mod;
}
@@ -230,10 +230,9 @@ public class ArrayHashSet<E>
*/
public final boolean retainAll(Collection<?> c) {
boolean mod = false;
- for (Iterator<?> iter = this.iterator(); iter.hasNext(); ) {
- Object o = iter.next();
- if (! c.contains(o) ) {
- mod = this.remove(o) || mod;
+ for (Object o : c) {
+ if (!c.contains(o)) {
+ mod |= this.remove(o);
}
}
return mod;