2828import com .arangodb .internal .util .ArangoSerializationFactory .Serializer ;
2929import com .arangodb .velocypack .VPackSlice ;
3030
31+ import java .util .Iterator ;
3132import java .util .NoSuchElementException ;
3233
3334/**
3738public class ArangoCursorIterator <T > implements ArangoIterator <T > {
3839
3940 private CursorEntity result ;
40- private int pos ;
41+ private Iterator < VPackSlice > arrayIterator ;
4142
4243 private final ArangoCursor <T > cursor ;
4344 private final InternalArangoDatabase <?, ?> db ;
@@ -50,7 +51,7 @@ protected ArangoCursorIterator(final ArangoCursor<T> cursor, final ArangoCursorE
5051 this .execute = execute ;
5152 this .db = db ;
5253 this .result = result ;
53- pos = 0 ;
54+ arrayIterator = result . getResult (). arrayIterator () ;
5455 }
5556
5657 public CursorEntity getResult () {
@@ -59,19 +60,19 @@ public CursorEntity getResult() {
5960
6061 @ Override
6162 public boolean hasNext () {
62- return pos < result . getResult (). size () || result .getHasMore ();
63+ return arrayIterator . hasNext () || result .getHasMore ();
6364 }
6465
6566 @ Override
6667 public T next () {
67- if (pos >= result . getResult (). size () && result .getHasMore ()) {
68+ if (! arrayIterator . hasNext () && result .getHasMore ()) {
6869 result = execute .next (cursor .getId (), result .getMeta ());
69- pos = 0 ;
70+ arrayIterator = result . getResult (). arrayIterator () ;
7071 }
7172 if (!hasNext ()) {
7273 throw new NoSuchElementException ();
7374 }
74- return deserialize (result . getResult (). get ( pos ++ ), cursor .getType ());
75+ return deserialize (arrayIterator . next ( ), cursor .getType ());
7576 }
7677
7778 protected <R > R deserialize (final VPackSlice result , final Class <R > type ) {
0 commit comments