"Steeve" <st**********@hotmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hi,
I found a way to get result than I want with this anonymus method. But,
it's a little weird to use a anonymus methods in another anonymus
methods. Moreover, i have a performance issue. How can I resolve this ?
Note : NodeList is a List<Nodeand ArcSuccList is a List<Arc>
Node findedNode = this.NodeList.Find(delegate(Node n)
{
if (n.Visited == true)
{ return false; }
else
{
return n.ArcSuccList.TrueForAll(delegate(Arc a)
{
return a.Visited == true;
});
}
});
Why do you think anonymous methods are the source of your performance
problem? Do you find that this code takes considerably longer that the
equivalent code written with nested for loops? There IS a cost associated
with invoking a method via a delegate, but that cost is small. There's
nothing special about anonymous methods that would change that cost unless
the anonymous method has to capture local variables from context. In that
case, each instantiation of the anonymous method will allocate an object on
the GC heap that holds the captured variables. In the code above, there
shouldn't be any captures, so the anonymous method shouldn't have any
unexpected performance overhead.
-cd