You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2016/07/31 02:03:47 UTC
groovy git commit: GROOVY-7629: ObjectRange methods duplicate
functionality and should not rely on size (revert incomplete attempt to make
iterator method thread-safe)
Repository: groovy
Updated Branches:
refs/heads/master 613822f2b -> 668c62858
GROOVY-7629: ObjectRange methods duplicate functionality and should not rely on size (revert incomplete attempt to make iterator method thread-safe)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/668c6285
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/668c6285
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/668c6285
Branch: refs/heads/master
Commit: 668c628588c3e66d258266e5bbf07c7010b38284
Parents: 613822f
Author: paulk <pa...@asert.com.au>
Authored: Sun Jul 31 12:03:21 2016 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Sun Jul 31 12:03:21 2016 +1000
----------------------------------------------------------------------
src/main/groovy/lang/ObjectRange.java | 26 +++++---------------------
1 file changed, 5 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/668c6285/src/main/groovy/lang/ObjectRange.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/ObjectRange.java b/src/main/groovy/lang/ObjectRange.java
index d6e0f4e..8741c9b 100644
--- a/src/main/groovy/lang/ObjectRange.java
+++ b/src/main/groovy/lang/ObjectRange.java
@@ -374,8 +374,9 @@ public class ObjectRange extends AbstractList<Comparable> implements Range<Compa
}
/**
- * iterates over all values and returns true if one value matches.
- * Also see containsWithinBounds.
+ * Iterates over all values and returns true if one value matches.
+ *
+ * @see #containsWithinBounds(Object)
*/
@Override
public boolean contains(Object value) {
@@ -406,28 +407,11 @@ public class ObjectRange extends AbstractList<Comparable> implements Range<Compa
@Override
public Iterator<Comparable> iterator() {
// non thread-safe iterator
- final Iterator<Comparable> innerIterator = new StepIterator(this, 1);
- return new Iterator<Comparable>() {
- @Override
- public synchronized boolean hasNext() {
- return innerIterator.hasNext();
- }
-
- @Override
- public synchronized Comparable next() {
- return innerIterator.next();
- }
-
- @Override
- public synchronized void remove() {
- innerIterator.remove();
- }
- };
+ return new StepIterator(this, 1);
}
/**
- * convenience class to serve in other methods.
- * It's not thread-safe, and lazily produces the next element only on calls of hasNext() or next()
+ * Non-thread-safe iterator which lazily produces the next element only on calls of hasNext() or next()
*/
private static class StepIterator implements Iterator<Comparable> {
// actual step, can be +1 when desired step is -1 and direction is from high to low