Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Payotz via Digitalmars-d-learn
Thank you all for the replies. I'm extremely grateful. I'll look into each and every answer.

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 1 December 2016 at 23:51:19 UTC, Payotz wrote: The register method will take in delegates as an argument, but those delegates have varied arguments themselves, so I can't really put anything there. I know that it's got something to do with templates so I tried my hand in it and

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 December 2016 at 23:51:19 UTC, Payotz wrote: So, to give context, I am trying to make an event manager for a game I'm making. I was writing the "register()" method so I ran into a problem. The register method will take in delegates as an argument, but those delegates have

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread crimaniak via Digitalmars-d-learn
On Thursday, 1 December 2016 at 23:51:19 UTC, Payotz wrote: So, to give context, I am trying to make an event manager for a game I'm making. I was writing the "register()" method so I ran into a problem. The register method will take in delegates as an argument, but those delegates have

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Ali Çehreli via Digitalmars-d-learn
On 12/01/2016 03:51 PM, Payotz wrote: > So, to give context, I am trying to make an event manager for a game I'm > making. > I was writing the "register()" method so I ran into a problem. > > The register method will take in delegates as an argument, but those > delegates have varied arguments

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 01, 2016 at 11:51:19PM +, Payotz via Digitalmars-d-learn wrote: > So, to give context, I am trying to make an event manager for a game > I'm making. > I was writing the "register()" method so I ran into a problem. > > The register method will take in delegates as an argument, but

Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Payotz via Digitalmars-d-learn
So, to give context, I am trying to make an event manager for a game I'm making. I was writing the "register()" method so I ran into a problem. The register method will take in delegates as an argument, but those delegates have varied arguments themselves, so I can't really put anything

Re: array of delegates

2016-04-14 Thread Alex via Digitalmars-d-learn
On Thursday, 14 April 2016 at 06:27:29 UTC, Ali Çehreli wrote: On 04/13/2016 04:39 PM, Alex wrote: > import std.algorithm; > indarr.map!(a => partial!(sg, a)); I think you want to generate a different delegate for each element where the first argument to sg is the value of that element (0,

Re: array of delegates

2016-04-14 Thread Alex via Digitalmars-d-learn
On Thursday, 14 April 2016 at 05:54:38 UTC, David Skluzacek wrote: So, that message is a pretty cryptic, but the problem there is that map does its thing at runtime, but partial is a template and must be instantiated at compile time. Instead you can use std.meta.staticMap, by doing something

Re: array of delegates

2016-04-14 Thread Ali Çehreli via Digitalmars-d-learn
On 04/13/2016 04:39 PM, Alex wrote: > import std.algorithm; > indarr.map!(a => partial!(sg, a)); I think you want to generate a different delegate for each element where the first argument to sg is the value of that element (0, 1, etc.). Since the second element of sg is a Props, you then

Re: array of delegates

2016-04-13 Thread David Skluzacek via Digitalmars-d-learn
So, that message is a pretty cryptic, but the problem there is that map does its thing at runtime, but partial is a template and must be instantiated at compile time. Instead you can use std.meta.staticMap, by doing something like this: void main() { import std.stdio; import

array of delegates

2016-04-13 Thread Alex via Digitalmars-d-learn
Hi at all! Having read this: http://forum.dlang.org/post/mailman.2415.1354291433.5162.digitalmars-d-le...@puremagic.com still have a problem... Lets begin with what works: enum Props{p1, p2} class AA { int[] arr1; int[] arr2; this() { //arbitrary values... arr1

problem with array of delegates!

2011-06-19 Thread Lloyd Dupont
the following code seem problematic to compile... import std.algorithm; private alias void delegate(int, int) SlotDelegate; class A { void DIT(int a, int b) { } } int main(string[] argv) { A a; SlotDelegate x= a.DIT; SlotDelegate[] _slotDg; _slotDg.remove(x);

Re: problem with array of delegates!

2011-06-19 Thread Andrej Mitrovic
Remove takes an offset, not a value as far as I know. If you need fast lookup and removal you could use hashes instead: int main(string[] argv) { auto a = new A; SlotDelegate x = a.DIT; bool[SlotDelegate] _slotDg; _slotDg.remove(x); return 0; }

Re: problem with array of delegates!

2011-06-19 Thread Lloyd Dupont
There is a remove() method in std.algorithm!I even got asked why I was reimplementing it! (well, because I didn't know it existed hey!) works fine with, say, int... but not with delegate! associative array will solve the problem indeed.. (I hope) but they use way more memory! it would be