Thread overview
opApply() question
Apr 02, 2004
Kris
Apr 02, 2004
Matthew
Apr 02, 2004
Kris
Apr 02, 2004
Matthew
Apr 02, 2004
Kris
April 02, 2004
to support foreach() on a class, one implements the opApply() method with
the signature: int opApply (int delegate(inout Type) dg)

This is for iterating across all elements within the class (container). How
does one specify an opApply() that is capable of filtering which elements it
exposes?

For example: if I have a directory of names versus phone-numbers, how do I
set up foreach() and opApply() to return only those elements that match a
given surname?

- Kris


April 02, 2004
"Kris" <someidiot@earthlink.dot.dot.dot.net> wrote in message news:c4in3o$2a00$1@digitaldaemon.com...
> to support foreach() on a class, one implements the opApply() method with
> the signature: int opApply (int delegate(inout Type) dg)
>
> This is for iterating across all elements within the class (container).
How
> does one specify an opApply() that is capable of filtering which elements
it
> exposes?
>
> For example: if I have a directory of names versus phone-numbers, how do I
> set up foreach() and opApply() to return only those elements that match a
> given surname?

You don't. Instead, you'd have a method - filter(char[] surname) - that returns something that is itself freachable, and which applies your filtering to the sequence provided by the directory's freachable range.


April 02, 2004
Cheers Matthew; that's just what I ended up doing -- adding little factory methods for creating filtering freachables.

- Kris


"Matthew" <matthew@stlsoft.org> wrote in message news:c4j8ob$6df$1@digitaldaemon.com...
>
> "Kris" <someidiot@earthlink.dot.dot.dot.net> wrote in message news:c4in3o$2a00$1@digitaldaemon.com...
> > to support foreach() on a class, one implements the opApply() method
with
> > the signature: int opApply (int delegate(inout Type) dg)
> >
> > This is for iterating across all elements within the class (container).
> How
> > does one specify an opApply() that is capable of filtering which
elements
> it
> > exposes?
> >
> > For example: if I have a directory of names versus phone-numbers, how do
I
> > set up foreach() and opApply() to return only those elements that match
a
> > given surname?
>
> You don't. Instead, you'd have a method - filter(char[] surname) - that returns something that is itself freachable, and which applies your filtering to the sequence provided by the directory's freachable range.
>
>


April 02, 2004
Cool. I'd like to see them when you're comfortable to share. :)

"Kris" <someidiot@earthlink.dot.dot.dot.net> wrote in message news:c4jcgu$cpa$1@digitaldaemon.com...
> Cheers Matthew; that's just what I ended up doing -- adding little factory methods for creating filtering freachables.
>
> - Kris
>
>
> "Matthew" <matthew@stlsoft.org> wrote in message news:c4j8ob$6df$1@digitaldaemon.com...
> >
> > "Kris" <someidiot@earthlink.dot.dot.dot.net> wrote in message news:c4in3o$2a00$1@digitaldaemon.com...
> > > to support foreach() on a class, one implements the opApply() method
> with
> > > the signature: int opApply (int delegate(inout Type) dg)
> > >
> > > This is for iterating across all elements within the class
(container).
> > How
> > > does one specify an opApply() that is capable of filtering which
> elements
> > it
> > > exposes?
> > >
> > > For example: if I have a directory of names versus phone-numbers, how
do
> I
> > > set up foreach() and opApply() to return only those elements that
match
> a
> > > given surname?
> >
> > You don't. Instead, you'd have a method - filter(char[] surname) - that returns something that is itself freachable, and which applies your filtering to the sequence provided by the directory's freachable range.
> >
> >
>
>


April 02, 2004
Certainly. This particular one was related to the traversal of HTTP headers in the Dsc package.

- Kris

"Matthew" <matthew@stlsoft.org> wrote in message news:c4juoc$18se$1@digitaldaemon.com...
> Cool. I'd like to see them when you're comfortable to share. :)
>
> "Kris" <someidiot@earthlink.dot.dot.dot.net> wrote in message news:c4jcgu$cpa$1@digitaldaemon.com...
> > Cheers Matthew; that's just what I ended up doing -- adding little
factory
> > methods for creating filtering freachables.
> >
> > - Kris
> >
> >
> > "Matthew" <matthew@stlsoft.org> wrote in message news:c4j8ob$6df$1@digitaldaemon.com...
> > >
> > > "Kris" <someidiot@earthlink.dot.dot.dot.net> wrote in message news:c4in3o$2a00$1@digitaldaemon.com...
> > > > to support foreach() on a class, one implements the opApply() method
> > with
> > > > the signature: int opApply (int delegate(inout Type) dg)
> > > >
> > > > This is for iterating across all elements within the class
> (container).
> > > How
> > > > does one specify an opApply() that is capable of filtering which
> > elements
> > > it
> > > > exposes?
> > > >
> > > > For example: if I have a directory of names versus phone-numbers,
how
> do
> > I
> > > > set up foreach() and opApply() to return only those elements that
> match
> > a
> > > > given surname?
> > >
> > > You don't. Instead, you'd have a method - filter(char[] surname) -
that
> > > returns something that is itself freachable, and which applies your filtering to the sequence provided by the directory's freachable
range.
> > >
> > >
> >
> >
>
>