www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Simple and quite easy to use iterator library for D

reply Witold Baryluk <baryluk mpi.int.pl> writes:
Hello,

http://smp.if.uj.edu.pl/~baryluk/d/iterators-1.0.tar.gz

documentation and samples included.

Feel free to comment, providing bug report, or nice examples. :)

Performance note: about 5% slowdown in comparison to hand writen loops.

Examples:


 class Naturals(int n) {
    int iter() {
       for (int i = 1; i <= n; i++) yield(i); 
       return 0;
    }
    mixin mainiter!(int, iter);   // mixin iterator's stuff
  }
  ...
  foreach (int x; new Naturals!(10)()) {
      ...
  }


Multiple iterators:

  class MNaturals(int n) {
   int iter2(Iterator!(double) x) {
       for (int i = 1; i <= n; i++) x.yield(i*i);
       return 0;
   }
   mixin inneriter!(double, iter2) squers;
   int iter3(Iterator!(double) x) {
       for (int i = 1; i <= n; i++) x.yield(i*i*i);
       return 0;
   }
   mixin inneriter!(double, iter3) qubes;
 }
  ...
  auto s = new MNaturals!(10)();
  foreach (int x; s.squers.ic()) {
      ...
  }
  foreach (int x; s.qubes.ic()) {
      ...
  }



-- 
Witold Baryluk
Jan 28 2007
next sibling parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Witold Baryluk wrote:
 Hello,
 
 http://smp.if.uj.edu.pl/~baryluk/d/iterators-1.0.tar.gz
 
 documentation and samples included.
 
 Feel free to comment, providing bug report, or nice examples. :)
 
 Performance note: about 5% slowdown in comparison to hand writen loops.
 

Is it compatible with Tango. ;-P --bb
Jan 28 2007
prev sibling next sibling parent BCS <BCS pathlink.com> writes:
Witold Baryluk wrote:
 Hello,
 
 http://smp.if.uj.edu.pl/~baryluk/d/iterators-1.0.tar.gz
 
 documentation and samples included.
 
 Feel free to comment, providing bug report, or nice examples. :)
 
 

You looking for SVN hosting?? If you want, I'll let you put it in scrapple on dsource.
Jan 29 2007
prev sibling parent reply Witold Baryluk <baryluk mpi.int.pl> writes:
Dnia Mon, 29 Jan 2007 11:17:26 -0800
BCS <BCS pathlink.com> napisa=B3/a:

 Witold Baryluk wrote:
 Hello,
=20
 http://smp.if.uj.edu.pl/~baryluk/d/iterators-1.0.tar.gz
=20
 documentation and samples included.
=20
 Feel free to comment, providing bug report, or nice examples. :)
=20
=20

You looking for SVN hosting?? If you want, I'll let you put it in=20 scrapple on dsource.

Thx, feel free to do this. I have, svn and cvs hosting, on two big servers. But they are for private development. I will probably, configure everything after exams in my school, and make some nice page for this and other (not completed) D programs, and other discontinued projects in C (now i will probably enthusiastically port them to D quickly, and release them - 5 of them can be really useful :D). Unfortunetly i can't legally point any non-edu domain to these servers, so i also don't see a point in creating special page for it. Ah, and i have some problems with forward references (like bug#102) in dmd, and can't go with development. :( --=20 Witold Baryluk MAIL: baryluk smp.if.uj.edu.pl, baryluk mpi.int.pl JID: movax jabber.autocom.pl
Jan 30 2007
parent BCS <ao pathlink.com> writes:
Reply to Witold,

 Dnia Mon, 29 Jan 2007 11:17:26 -0800
 BCS <BCS pathlink.com> napisal/a:
 Witold Baryluk wrote:
 
 Hello,
 
 http://smp.if.uj.edu.pl/~baryluk/d/iterators-1.0.tar.gz
 
 documentation and samples included.
 
 Feel free to comment, providing bug report, or nice examples. :)
 

scrapple on dsource.


If you have a dsource account I'll set you up with dev access. Just send me a username. I'll dump in the tar and add the .html for now.
Jan 30 2007