Any chance to call Tango as Extended Standard Library
Michel Fortin
michel.fortin at michelf.com
Thu Jan 22 18:53:02 PST 2009
On 2009-01-19 18:11:15 -0500, Sergey Gromov <snake.scaly at gmail.com> said:
> I think "can't" is a bit strong a statement. Let's see:
>
> With opApply:
>
> class progressUpdater(Collection)
> {
> this(Collection c)
> {
> collection_ = c;
> }
>
> int opApply(int delegate(ref ElementType!(Collection)) dg)
> {
> composed_ = dg;
> return collection_.opApply(&fancifier);
> }
>
> private:
>
> int fancifier(ref ElementType!(Collection) el)
> {
> globalOnProgress();
> return composed_(el);
> }
>
> Collection collection_;
> int delegate(ref ElementType!(Collection)) composed_;
> }
I think it's the same as this:
class progressUpdater(Collection)
{
this(Collection c)
{
collection_ = c;
}
int opApply(int delegate(ref ElementType!(Collection)) dg)
{
int fancifier(ref ElementType!(Collection) el)
{
globalOnProgress();
return composed_(el);
}
composed_ = dg;
return collection_.opApply(&fancifier);
}
private:
Collection collection_;
}
Or this:
class progressUpdater(Collection)
{
this(Collection c)
{
collection_ = c;
}
int opApply(int delegate(ref ElementType!(Collection)) dg)
{
foreach(ref ElementType!(Collection) el; collection_)
{
globalOnProgress();
if (dg(el))
return 1;
}
return 0;
}
private:
Collection collection_;
}
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list