package magic.data;

import java.util.ArrayList;
import java.util.Iterator;

import magic.data.impl.ListIndexSeq;

public class Tools {

	public static <T> ISeq<T> seq(Iterator<T> iterator) {
		ArrayList<T> list=new ArrayList<T>();
		while(iterator.hasNext()) {
			list.add(iterator.next());
		}
		return new ListIndexSeq<T>(list);
	}

}

@@ -185,16 +185,56 @@
 ator) %7B%0A
+%09%09if (!iterator.hasNext()) return null;%0A
 %09%09ArrayL
@@ -271,33 +271,10 @@
 ;%0A%09%09
-while(iterator.hasNext())
+do
  %7B%0A%09
@@ -305,16 +305,45 @@
 ());%0A%09%09%7D
+ while (iterator.hasNext());%0A
 %0A%09%09retur

Fix seq for empty iterators