浏览代码

added count()

Nicolas Cannasse 19 年之前
父节点
当前提交
b602f8198f
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      std/Lambda.hx

+ 10 - 0
std/Lambda.hx

@@ -79,4 +79,14 @@ class Lambda<A,B> {
 		return first;
 	}
 
+	/**
+		Count the number of elements in an [Iterator]
+	**/
+	public static function count( it : Iterator<A> ) {
+		var n = 0;
+		for( _ in it )
+			++n;
+		return n;
+	}
+
 }