Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added adaptor to Iterator.

  • Loading branch information...
commit 6e2f839095332a0b87a626ca41724a05fef66758 1 parent 03ef265
@andyli authored
View
2  hxLINQ/LINQ.hx
@@ -30,5 +30,7 @@ class OrderedLINQ<T,C:Iterable<T>> extends LINQ<T,C> {
typedef LINQtoIterable = hxLINQ.iterable.LINQtoIterable;
typedef OrderedLINQtoIterable = hxLINQ.iterable.OrderedLINQtoIterable;
+typedef LINQtoIterator = hxLINQ.iterable.LINQtoIterator;
+
typedef LINQtoArray = hxLINQ.iterable.LINQtoArray;
typedef OrderedLINQtoArray = hxLINQ.iterable.OrderedLINQtoArray;
View
11 hxLINQ/iterable/LINQtoIterator.hx
@@ -0,0 +1,11 @@
+package hxLINQ.iterable;
+
+using hxLINQ.LINQ;
+
+class LINQtoIterator {
+ static public function linq<T>(iterator:Iterator<T>):LINQ<T,Iterable<T>> {
+ return new LINQ({
+ iterator:function() return iterator
+ });
+ }
+}
View
8 test/Test.hx
@@ -470,6 +470,14 @@ class Test extends haxe.unit.TestCase{
this.assertEquals(10,r.count());
this.assertEquals("9,8,1,7,3,4,6,10,2,5",r.toArray().join(","));
}
+
+ public function testIterator():Void {
+ var hash = new Hash<Int>();
+ for (i in 65...70) hash.set(String.fromCharCode(i), i);
+
+ var r = hash.keys().linq();
+ this.assertEquals(5, r.count());
+ }
static public var people:Array<Person> = [
{ id: 1, firstName: "Chris", lastName: "Pearson", bookIds: [1001, 1002, 1003] },
Please sign in to comment.
Something went wrong with that request. Please try again.