Skip to content

Commit

Permalink
write uIterator description in README
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel59 committed Jul 20, 2014
1 parent 1450cab commit 0c6df3b
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,28 @@ class Main {
}
}
}
```
```

## 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());
}
}
```

0 comments on commit 0c6df3b

Please sign in to comment.