From 6408c1f33072970f1b6269036498344e4611a415 Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 26 Mar 2017 15:59:22 +0300 Subject: [PATCH] LazyList implements RandomAccess Positional access in LazyList is as fast as sequential, positional for-each (`for (int i = 0; i < size; i++)`) is as fast as iterator for-each (`for (E e : list)`), and thus this class should implement java.util.RandomAccess. --- .../src/main/java/org/greenrobot/greendao/query/LazyList.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DaoCore/src/main/java/org/greenrobot/greendao/query/LazyList.java b/DaoCore/src/main/java/org/greenrobot/greendao/query/LazyList.java index 032ad7af2..d80c67b70 100644 --- a/DaoCore/src/main/java/org/greenrobot/greendao/query/LazyList.java +++ b/DaoCore/src/main/java/org/greenrobot/greendao/query/LazyList.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.ListIterator; import java.util.NoSuchElementException; +import java.util.RandomAccess; import java.util.concurrent.locks.ReentrantLock; import android.database.Cursor; @@ -42,7 +43,7 @@ * @param * Entity type. */ -public class LazyList implements List, Closeable { +public class LazyList implements List, Closeable, RandomAccess { protected class LazyIterator implements CloseableListIterator { private int index; private final boolean closeWhenDone;