From 0c6df3b933491cca456f18d99fd629dfa13bb197 Mon Sep 17 00:00:00 2001 From: Ryusei Yamaguchi Date: Sun, 20 Jul 2014 22:01:37 +0900 Subject: [PATCH] write uIterator description in README --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fa40604..f5c8850 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,28 @@ class Main { } } } -``` \ No newline at end of file +``` + +## Iteration + +You would write iteration such that: + +```haxe +function f(s : String) : Void { + for (i in s.uLength()) { + trace(s.uCharAt(i)); + } +} +``` + +But `f(s)` has order of the square of the length of `s`. + +Instead, you can use `uIterator` to let the function be more efficient: + +```haxe +function f(s : String) : Void { + for (c in s.uIterator()) { + trace(c.toString()); + } +} +```