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