FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Text Iterators

 
Post new topic   Reply to topic     Forum Index -> Mango
View previous topic :: View next topic  
Author Message
teqdruid



Joined: 11 May 2004
Posts: 390
Location: UMD

PostPosted: Wed Mar 15, 2006 5:06 pm    Post subject: Text Iterators Reply with quote

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?
Back to top
View user's profile Send private message Send e-mail AIM Address
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Wed Mar 15, 2006 9:49 pm    Post subject: Reply with quote

Sure!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Mango All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group