I would not like to add to the overhead of ArrayList's iterator.
Those writing performance-critical code are avoiding the iterator and doing
for (int i = 0, limit = list.size(); i < limit; i++) {
E elt = list.get(i);
...
}
On Thu, Jan 8, 2015 at 12:11 AM, Remi Forax wrote:
>
> On 01/08/201
> On 01/08/2015 03:24 AM, David Holmes wrote:
>>
>> So don't do that.
>
Yes, don't. However, it can happen unintentionally and such an exception helps
catch bugs. This can more easily occur when there is some "distance" between
iterating and operating on the list. So it's about strengthening
On 01/08/2015 03:24 AM, David Holmes wrote:
On 7/01/2015 7:45 PM, Remi Forax wrote:
A simple Java question, what this code does ?
ArrayList list = new ArrayList<>();
list.add("foo");
list.add("bar");
for(String s: list) {
list.remove(s);
}
:(
Rémi
tip: the bug lies in Arr
On 7/01/2015 7:45 PM, Remi Forax wrote:
A simple Java question, what this code does ?
ArrayList list = new ArrayList<>();
list.add("foo");
list.add("bar");
for(String s: list) {
list.remove(s);
}
:(
Rémi
tip: the bug lies in ArrayList.Itr.hasNext() (and
AbstractList.Itr.has
On 01/07/2015 11:47 AM, Daniel Fuchs wrote:
On 07/01/15 11:31, Paul Sandoz wrote:
On Jan 7, 2015, at 10:45 AM, Remi Forax wrote:
A simple Java question, what this code does ?
ArrayList list = new ArrayList<>();
list.add("foo");
list.add("bar");
for(String s: list) {
list.remove
On 07/01/15 11:25, Doug Lea wrote:
On 01/07/2015 04:45 AM, Remi Forax wrote:
A simple Java question, what this code does ?
ArrayList list = new ArrayList<>();
list.add("foo");
list.add("bar");
for(String s: list) {
list.remove(s);
}
I have a vague recollection that this i
On 07/01/2015 11:25, Doug Lea wrote:
On 01/07/2015 04:45 AM, Remi Forax wrote:
A simple Java question, what this code does ?
ArrayList list = new ArrayList<>();
list.add("foo");
list.add("bar");
for(String s: list) {
list.remove(s);
}
I have a vague recollection that this
On Wednesday 07 January 2015 12:02:42 Chris Hegarty wrote:
> > Yes, but that exactly how it works now, that's why second invocation of
> > hasNext() returns false and we can see the issue Remi is talking about. If
> > hasNext() will be throwing ConcurrentModification than will work as early
> > war
On 07/01/15 11:22, Stanislav Baiduzhyi wrote:
On Wednesday 07 January 2015 11:20:57 you wrote:
On 07/01/15 10:57, Stanislav Baiduzhyi wrote:
On Wednesday 07 January 2015 10:56:01 Chris Hegarty wrote:
public boolean hasNext() {
-return cursor != size;
+retur
On Wednesday 07 January 2015 12:29:44 Mario Torre wrote:
> > Yes, but that exactly how it works now, that's why second invocation of
> > hasNext() returns false and we can see the issue Remi is talking about. If
> > hasNext() will be throwing ConcurrentModification than will work as early
> > warni
On Jan 7, 2015, at 11:56 AM, Chris Hegarty wrote:
> On 07/01/15 10:47, Daniel Fuchs wrote:
>> On 07/01/15 11:31, Paul Sandoz wrote:
>>>
>>> On Jan 7, 2015, at 10:45 AM, Remi Forax wrote:
>>>
A simple Java question, what this code does ?
ArrayList list = new ArrayList<>();
>>>
2015-01-07 12:22 GMT+01:00 Stanislav Baiduzhyi :
> On Wednesday 07 January 2015 11:20:57 you wrote:
>> On 07/01/15 10:57, Stanislav Baiduzhyi wrote:
>> > On Wednesday 07 January 2015 10:56:01 Chris Hegarty wrote:
>> >>public boolean hasNext() {
>> >>
>> >> -return cursor !=
On 01/07/2015 04:45 AM, Remi Forax wrote:
A simple Java question, what this code does ?
ArrayList list = new ArrayList<>();
list.add("foo");
list.add("bar");
for(String s: list) {
list.remove(s);
}
I have a vague recollection that this issue has come up before,
and that no
On Wednesday 07 January 2015 11:20:57 you wrote:
> On 07/01/15 10:57, Stanislav Baiduzhyi wrote:
> > On Wednesday 07 January 2015 10:56:01 Chris Hegarty wrote:
> >>public boolean hasNext() {
> >>
> >> -return cursor != size;
> >> +return cursor != itrSize;
> >>
If I'm not mistaken LinkedList and Vector demonstrate exactly the same buggy
behaviour.
-Pavel
> On 7 Jan 2015, at 11:20, Chris Hegarty wrote:
>
> On 07/01/15 10:57, Stanislav Baiduzhyi wrote:
>> On Wednesday 07 January 2015 10:56:01 Chris Hegarty wrote:
>>> public boolean hasNext() {
On 07/01/15 10:57, Stanislav Baiduzhyi wrote:
On Wednesday 07 January 2015 10:56:01 Chris Hegarty wrote:
public boolean hasNext() {
-return cursor != size;
+return cursor != itrSize;
}
If the user will invoke list.remove(E) to remove current or pre
On Wednesday 07 January 2015 10:56:01 Chris Hegarty wrote:
> public boolean hasNext() {
> -return cursor != size;
> +return cursor != itrSize;
> }
If the user will invoke list.remove(E) to remove current or previous element
then iterator will be skippin
On 07/01/15 10:47, Daniel Fuchs wrote:
On 07/01/15 11:31, Paul Sandoz wrote:
On Jan 7, 2015, at 10:45 AM, Remi Forax wrote:
A simple Java question, what this code does ?
ArrayList list = new ArrayList<>();
list.add("foo");
list.add("bar");
for(String s: list) {
list.remove(s);
On 07/01/15 11:31, Paul Sandoz wrote:
On Jan 7, 2015, at 10:45 AM, Remi Forax wrote:
A simple Java question, what this code does ?
ArrayList list = new ArrayList<>();
list.add("foo");
list.add("bar");
for(String s: list) {
list.remove(s);
}
:(
We could improve the best-effo
On Jan 7, 2015, at 10:45 AM, Remi Forax wrote:
> A simple Java question, what this code does ?
>
> ArrayList list = new ArrayList<>();
> list.add("foo");
> list.add("bar");
> for(String s: list) {
>list.remove(s);
> }
>
> :(
>
We could improve the best-effort basis by which Concurre
Interesting... I would have expected it to throw
java.util.ConcurrentModificationException right
away, but it only does so if the list contains
exactly 1 or more than 2 elements...
best regards,
-- daniel
On 07/01/15 10:45, Remi Forax wrote:
A simple Java question, what this code does ?
A
On Wednesday 07 January 2015 10:45:46 Remi Forax wrote:
> A simple Java question, what this code does ?
>
>ArrayList list = new ArrayList<>();
>list.add("foo");
>list.add("bar");
>for(String s: list) {
> list.remove(s);
>}
>
> :(
>
> Rémi
> tip: the bug lies in ArrayList
22 matches
Mail list logo