Skip to content

Commit 43a48c6

Browse files
committed
BridJ: fixed issue #37 (allow iterating on unbound pointers).
1 parent 228e82e commit 43a48c6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • libraries/Runtime/BridJ/src/main/velocity/org/bridj

libraries/Runtime/BridJ/src/main/velocity/org/bridj/Pointer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,15 +547,16 @@ public long getValidElements() {
547547
*/
548548
public ListIterator<T> iterator() {
549549
return new ListIterator<T>() {
550-
Pointer<T> next = Pointer.this.getValidElements() > 0 ? Pointer.this : null;
550+
Pointer<T> next = Pointer.this.getValidElements() != 0 ? Pointer.this : null;
551551
Pointer<T> previous;
552552
@Override
553553
public T next() {
554554
if (next == null)
555555
throw new NoSuchElementException();
556556
T value = next.get();
557557
previous = next;
558-
next = next.getValidElements() > 1 ? next.next(1) : null;
558+
long valid = next.getValidElements();
559+
next = valid < 0 || valid > 1 ? next.next(1) : null;
559560
return value;
560561
}
561562
@Override

0 commit comments

Comments
 (0)