EagerForeignCollection iterator - remove behaviour (Android)

30 views
Skip to first unread message

Almighty

unread,
Jun 16, 2013, 1:47:59 PM6/16/13
to ormlit...@googlegroups.com
Firstly... Many thanks for this awesome library, it saved me a lot of time.
Secondly I'd like to report incorrect (in sense of being different from other iterators in Java library) behaviour of iterator that is returned by the iterator() method of EagerForeignCollection. 

The problem occurs when I iterate some ForeignCollection and call remove(). Every time I call remove, the next call of next() results in skipping one record.
Let's say I'd like to delete all records using iterator:

 for (Iterator<SomeEntity> iterator = fCol.iterator(); iterator.hasNext();) {
    SomeEntity SomeEntity = (SomeEntity) iterator.next();
    iterator.remove();
 }

After this being executed, only entities with odd indices (1,3,5...) are removed. When I use this example with an ArrayList it leads to empty list.

I'm using the latest (4.45) version on Android Jelly bean. 

Thanks,
Pavel
Reply all
Reply to author
Forward
0 new messages