teqdruid
Joined: 11 May 2004 Posts: 390 Location: UMD
|
Posted: Wed Mar 15, 2006 5:06 pm Post subject: Text Iterators |
|
|
Code: | Index: mango/text/Iterator.d
===================================================================
--- mango/text/Iterator.d (revision 807)
+++ mango/text/Iterator.d (working copy)
@@ -223,6 +223,30 @@
/**********************************************************************
+ Iterate over the set of tokens. This should really
+ provide read-only access to the tokens, but D does
+ not support that at this time
+
+ **********************************************************************/
+
+ int opApply (int delegate(inout uint, inout T[]) dg)
+ {
+ int result = 0;
+ uint count = 0;
+
+ while (next)
+ {
+ count++;
+ T[] t = get ();
+ result = dg (count, t);
+ if (result)
+ break;
+ }
+ return result;
+ }
+
+ /**********************************************************************
+
Visit each token by passing them to the provided delegate
**********************************************************************/
|
I needed an index in a small program I was writing. OK with you to commit, Kris? |
|