Skip to content

Commit

Permalink
implement individual CodePointIter class
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel59 committed Nov 23, 2014
1 parent ae1f289 commit 839010b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
19 changes: 19 additions & 0 deletions unifill/CodePointIter.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package unifill;

class CodePointIter {
var s : String;
var itr : InternalEncodingIter;

public inline function new(s : String) {
this.s = s;
this.itr = new InternalEncodingIter(s, 0, s.length);
}

public inline function hasNext() : Bool {
return itr.hasNext();
}

public inline function next() : CodePoint {
return cast InternalEncoding.codePointAt(s, itr.next());
}
}
6 changes: 1 addition & 5 deletions unifill/Unifill.hx
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ class Unifill {
Returns an iterator of the code points of String `s`.
**/
public static inline function uIterator(s : String) : Iterator<CodePoint> {
var itr = new InternalEncodingIter(s, 0, s.length);
return {
hasNext: itr.hasNext,
next: function() return cast InternalEncoding.codePointAt(s, itr.next())
};
return new CodePointIter(s);
}

/**
Expand Down

0 comments on commit 839010b

Please sign in to comment.