D - opApply() question
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
Apr 01 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).Howdoes one specify an opApply() that is capable of filtering which elementsitexposes? 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.
Apr 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...withto support foreach() on a class, one implements the opApply() methodelementsthe signature: int opApply (int delegate(inout Type) dg) This is for iterating across all elements within the class (container).Howdoes one specify an opApply() that is capable of filtering whichitIexposes? For example: if I have a directory of names versus phone-numbers, how doaset up foreach() and opApply() to return only those elements that matchgiven 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.
Apr 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...(container)."Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message news:c4in3o$2a00$1 digitaldaemon.com...withto support foreach() on a class, one implements the opApply() methodthe signature: int opApply (int delegate(inout Type) dg) This is for iterating across all elements within the classdoHowelementsdoes one specify an opApply() that is capable of filtering whichitexposes? For example: if I have a directory of names versus phone-numbers, howImatchset up foreach() and opApply() to return only those elements thatagiven 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.
Apr 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...factoryCheers Matthew; that's just what I ended up doing -- adding littlehowmethods for creating filtering freachables. - Kris "Matthew" <matthew stlsoft.org> wrote in message news:c4j8ob$6df$1 digitaldaemon.com...(container)."Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message news:c4in3o$2a00$1 digitaldaemon.com...withto support foreach() on a class, one implements the opApply() methodthe signature: int opApply (int delegate(inout Type) dg) This is for iterating across all elements within the classHowelementsdoes one specify an opApply() that is capable of filtering whichitexposes? For example: if I have a directory of names versus phone-numbers,dothatImatchset up foreach() and opApply() to return only those elements thatagiven surname?You don't. Instead, you'd have a method - filter(char[] surname) -range.returns something that is itself freachable, and which applies your filtering to the sequence provided by the directory's freachable
Apr 02 2004