소스 검색

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;
+	}
+
 }